{"record":{"id":"c3e232bf7035f80a","repo":"languagetool-org/languagetool","slug":"could-not-create-languagetool-instance-for-languag","errorCode":null,"errorMessage":"Could not create LanguageTool instance for language <language>","messagePattern":"Could not create LanguageTool instance for language <language>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-commandline/src/main/java/org/languagetool/commandline/Main.java","lineNumber":362,"sourceCode":"      String fileContents = readerToString(reader);\n      if (xmlFiltering) {\n        return filterXML(fileContents);\n      } else {\n        return fileContents;\n      }\n    }\n  }\n\n  private void changeLanguage(Language language, Language motherTongue,\n                              List<String> disabledRules, List<String> enabledRules) {\n    try {\n      lt = new MultiThreadedJLanguageTool(language, motherTongue);\n      Tools.selectRules(lt, disabledRules, enabledRules, true);\n      if (options.isVerbose()) {\n        lt.setOutput(System.err);\n      }\n    } catch (Exception e) {\n      throw new RuntimeException(\"Could not create LanguageTool instance for language \" + language, e);\n    }\n  }\n\n  @FunctionalInterface\n  interface SystemExitHandler {\n    void exit(int status);\n    SystemExitHandler DEFAULT = System::exit;\n  }\n\n  static SystemExitHandler exitHandler = SystemExitHandler.DEFAULT;\n\n  /**\n   * Command line tool to check plain text files.\n   */\n  public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException {\n    JnaTools.setBugWorkaroundProperty();\n    CommandLineParser commandLineParser = new CommandLineParser();\n    CommandLineOptions options = null;","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-commandline/src/main/java/org/languagetool/commandline/Main.java#L344-L380","documentation":"Main.changeLanguage builds a MultiThreadedJLanguageTool for the requested language and selects rules; any Exception there is rethrown as this RuntimeException. It means the LanguageTool instance for the given language code could not be constructed or its rules could not be selected.","triggerScenarios":"Calling the CLI with a -l/--language value whose Language instance fails initialization, or with --disable/--enable rule ids that make Tools.selectRules throw (e.g. a rule id referencing something invalid), or mother-tongue lookup failing.","commonSituations":"Unsupported or misspelled language code on the command line; corrupted/incomplete language resource deployment; enabling/disabling rules that don't exist for that language in that version.","solutions":["Check the 'Caused by' exception for the real initialization failure.","Verify the language code with `languagetool --list` or the supported-languages list for your version.","Remove/verify --enable and --disable rule ids; confirm they exist for the chosen language.","Reinstall/upgrade LanguageTool if language resources are missing from the distribution."],"exampleFix":"// before\nlanguagetool -l eng -c UTF-8 file.txt\n// after\nlanguagetool -l en-US -c UTF-8 file.txt","handlingStrategy":"validation","validationCode":"Language lang = Languages.getLanguageForShortCode(langCode); // throws early if unsupported\n// also verify rule ids exist:\n// lt.getRuleForId(...) or check --list output before running","typeGuard":null,"tryCatchPattern":"try {\n  Language lang = Languages.getLanguageForShortCode(code);\n} catch (IllegalArgumentException e) {\n  System.err.println(\"Unsupported language code: \" + code);\n  System.exit(2);\n}","preventionTips":["Validate language short codes with Languages.getLanguageForShortCode before use.","Keep all LanguageTool artifacts on one version.","Verify --enable/--disable ids against the language's rule list."],"tags":["cli","initialization","language-config","runtime-exception"],"backgroundTag":"invalid-config-value","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}