IOException

Hello all,

I am using language tool api provided by you languagetool.jar. I have put all jars in class path also make jar for org directory and put it on class path but still i get an exception like,

Exception in thread “main” java.io.IOException: Cannot load or parse input stream of ‘/org/languagetool/rules/en/grammar.xml’
at org.languagetool.rules.patterns.PatternRuleLoader.getRules(PatternRuleLoader.java:74)
at org.languagetool.JLanguageTool.loadPatternRules(JLanguageTool.java:334)
at org.languagetool.JLanguageTool.activateDefaultPatternRules(JLanguageTool.java:370)
at Tester.main(Tester.java:13)
Caused by: java.lang.IllegalArgumentException: ‘en’ is not a language code known to LanguageTool. Supported language codes are: xx-XX
at org.languagetool.Language.getLanguageForShortName(Language.java:459)
at org.languagetool.rules.patterns.PatternRuleHandler.startElement(PatternRuleHandler.java:103)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.languagetool.rules.patterns.PatternRuleLoader.getRules(PatternRuleLoader.java:71)
… 3 more

Thanks in advance

You need a
language-module.properties
file. This is documented at Java API - LanguageTool Wiki.

I have put that file in class path of my java project but it still give that exception.

Did you put it to
META-INF/org/languagetool/language-module.properties
?

yes like this…

and also i build this file in class path in run configure

Placing the META-INF directly into ‘Demo’ will only work if ‘Demo’ itself (not just Demo/src) is actually in the classpath. Are you sure it is?