Jeremy Hunts Jeremy Hunts - 10 months ago 60
Java Question

java language tool library, cannot find dependency

I am using this example code to use the API. I don't want to use maven so I downloaded the jar files from here, and included the Jar files in org and lib to the build path, then tried to run the example code. I got this error:

Error:(15, 56) java: cannot find symbol
symbol: class BritishEnglish
location: class draft
Error:(3, 34) java: cannot find symbol
symbol: class BritishEnglish
location: package org.languagetool.language

here is my code

import org.languagetool.JLanguageTool;
import org.languagetool.language.BritishEnglish;
import org.languagetool.rules.RuleMatch;
import java.util.List;

public class draft {
public static void main(String[] args) throws IOException {

JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
// comment in to use statistical ngram data:
//langTool.activateLanguageModelRules(new File("/data/google-ngram-data"));
List<RuleMatch> matches = langTool.check("A sentence with a error in the Hitchhiker's Guide tot he Galaxy");
for (RuleMatch match : matches) {
System.out.println("Potential error at characters " +
match.getFromPos() + "-" + match.getToPos() + ": " +
System.out.println("Suggested correction(s): " +

I found this answer online, but I don't understand it.

" BritishEnglish is in the "org" directory and not in the JARs, but you can put in a JAR like this: "zip -r languages.jar org/", then add languages.jar to your classpath like the other JARs. "

Answer Source

The language implementations themselves are packed into separate jars, apparently. The one you need is in language-en.jar:

You can see it here:

jameson@spinach:~$ jar -tf language-en-3.5.jar | grep BritishEnglish

Try downloading and it and adding it to your classpath. Also be sure to do the items in the doc: . I don't recommend repacking a dependency jar, that's kludgy. I also do recommend using maven instead.