This will get the dependencies needed to check English. Use language-de as an artifactId for German etc. (show all artifacts). If you want to use all languages that LanguageTool supports, use language-all.

If you don't use Maven (or a similar system), download the stand-alone ZIP instead. You will need the JAR files in the libs directory, the org directory, and the META-INF directory in your classpath. We strongly recommend using Maven or Gradle instead.

To use LanguageTool, you just need to create a JLanguageTool object and use that to check your text. Also see the API documentation. For example:

Checking Text with Markup

LanguageTool usually works on plain text. If you need to check text with markup (HTML, XML, LaTeX, …) you usually cannot just remove the markup, as that would mess up the position information that LanguageTool returns. In this case, use AnnotatedTextBuilder to create an AnnotatedText object that tells LanguageTool which parts of your text are markup and which are text. There's a check method in JLanguageTool that accepts the AnnotatedText object.

Multi-Threading

The JLanguageTool class is not thread safe. Create one instance of JLanguageTool per thread, but create the language only once (e.g. new BritishEnglish()) and use that for all instances of JLanguageTool. The same is true for MultiThreadedJLanguageTool - its name refers to the fact that it uses threads internally, but it's not thread safe itself.

Spell Checking

If you want spell checking and the language you're working with has variants, you will need to specify that variant in the JLanguageTool constructor, e.g. new AmericanEnglish() instead of just new English().

To ignore words, i.e. exclude them from spell checking, call the addIgnoreTokens(…) method of the spell checking rule you're using. You first have to find the rule by iterating over all active rules. Example:

You either build that file yourself, adapted to the languages you support, or you take it from the LanguageTool stand-alone distribution. Of course, the classes referenced in that file actually need to be in your classpath.

Nightly Snapshots

Updating to new Releases

LanguageTool releases a new version every three months. While our API is generally quite stable, we sometimes make small changes that might affect your usage of the API. We recommend upgrading without skipping a version. So if you are using LanguageTool 2.2 and want to upgrade to 2.5, we recommend updating to 2.3 first, then to 2.4, then to 2.5. With each update, you should carefully look at the "API" section in our change log and re-compile the code that uses the LanguageTool API to see if there are deprecation warnings. If there are warnings, the javadoc we provide usually has a suggestion which method to use instead of the deprecated one.

Using a remote LanguageTool server

If you prefer to use a LanguageTool server to running LanguageTool in-process, use org.languagetool.remote.RemoteLanguageTool from the languagetool-http-client module. It takes care of sending the HTTP(S) request and parsing the XML result. For testing, feel free to use our public HTTPS API server. The advantage of using a remote server is lower CPU, memory, and disk usage for your local process, especially if you'd like to use ngram data for detecting commonly confused words.