Java classpath + split dependency error

Hi all,

Following the minimal example provided at Embedding LanguageTool in Java applications | dev.languagetool.org, I added the following Maven dependency to my pom.xml:
<dependency>
<groupId>org.languagetool</groupId>
<artifactId>language-en</artifactId>
<version>6.6</version>
</dependency>

and attempted to do the basic text checking with a JLanguageTool object.

This builds but throws an error: Class ‘org.languagetool.language.English’… not found in classpath.

Adding requires language.en to module-info resolves this error, but causes build to fail with: java: module org.apache.poi.poi reads package org.languagetool.chunking from both languagetool.core and language.en

I understand this could be a split dependency issue? Similar to this [Java 11] Dependencies & Requirements and this [jdk11] problem with dependencies · Issue #3303 · languagetool-org/languagetool · GitHub.

Haven’t found a way to resolve this so far. Would very much appreciate some help!!

Many thanks in advance.

Hi,

Which Java version are you using? As you linked some issues related to Java 11, I guess you are using Java 11 as well. Java 11 is not supported by LT 6.6. You need to use at least Java 17 or use LT 6.5.

Sorry, forgot to include this in the question - I’m using openjdk 21.0.10 2026-01-20 LTS (Corretto)

Is your code available on GitHub? If yes, I will try to build it myself.

Hi! This is a classic Java Module System (JPMS) split package issue.

LanguageTool artifacts historically share internal packages. In traditional classpath mode Java allows this, but JPMS strictly forbids two named modules from exporting the exact same package.

Here are a few ways to resolve this:

Option 1: Treat LanguageTool as Automatic Modules (Recommended)
Remove explicit requires language.en; from your module-info.java and let LanguageTool sit on the classpath.

Option 2: Explicitly Align Dependency Versions in pom.xml
Ensure languagetool-core and language-en use the exact same version:

<dependency>
    <groupId>org.languagetool</groupId>
    <artifactId>languagetool-core</artifactId>
    <version>6.6</version>
</dependency>
<dependency>
    <groupId>org.languagetool</groupId>
    <artifactId>language-en</artifactId>
    <version>6.6</version>
</dependency>

Option 3: Compiler Flag for JPMS
If keeping full modularity, add compiler flags in pom.xml:

<configuration>
    <compilerArgs>
        <arg>--add-reads</arg>
        <arg>language.en=languagetool.core</arg>
    </compilerArgs>
</configuration>

Hope this helps!