Java build issues - Java 8 to Java 11 migration

We're migrating from Java 8 to Java 11.
We have a legacy project Y which depends on another legacy project X.
The project X has no sources, it's just a collection of about 300 jars.
The build is ant-based, no maven.

I cannot build the project Y now with JDK 11 (neither in Eclipse, nor externally)
because it says "The package org.w3c.dom is accessible from more than one module: , java.xml"

I get this error in Eclipse on a line which does import org.w3c.dom.Document;

When I do an external build (with ant, outside of Eclipse) I can build successfully (with basically the same build.xml as under JDK 8)?! How come only Eclipse is complaining?! Is it because of this javac bug which I reference below.

I was reading here (these are directly related to my issues):

https://stackoverflow.com/a/53824670/2300597
The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml
http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-December/014077.html

but I am still unable to fix these build issues.
I tried 7-8 different things but nothing helps.

I think the clash is between org.w3c.dom package from some of these 300 jars and the same package in the JDK module java.xml.

The weird thing is that org.w3c.dom.Document doesn't seem to be present in any of these 300 jars, it's just that other classes from the same package are present in jars.

I am deadlocked, I see no way to fix this.
I cannot lightly change project X because it's a shared library used by multiple legacy projects.
On the other hand, I cannot remove java.xml module from the build path of project Y.
So I don't know how to approach this.

Isn't there some way to just say: OK, use the classes from the JDK first, then use those from the JARs (even though they share the same package, they are not the same class).

What is the right way to fix these errors?


Solution 1:

Starting from version 9 Java supports JPMS (Java Platform Module System).

In the Java Platform Module System it is not allowed to use the same package in more than one module. So, the solution is to find modules (jars) that exports this package org.w3c.dom and to remove one of the modules or package in it.