Migrating to Java 11: I need help resolving Classpath & Module Path Conflicts In Eclipse

3k Views Asked by At

I'm helping to migrate a large project ( Eclispe SWT, many plugins bundled together as one project ) from Java 8 to Java 11.

I was having trouble with import statements for javax.xml.stream.

Hovering over the import statement in Eclipse (Version: 2019-06 (4.12.0) ) I got this error message

The package javax.xml.stream is accessible from more than one module: <unnamed>, java.xml

Googling around this seemed like it might be about javax.xml being listed in both the new module path and the classpath.

I went to the top node of the project with the problem, right clicked, went to build path > configure build path, module dependencies, picked "javax.xml" and removed it.

That automagically made 8 compiler errors go away, but made two new ones appear:

The project was not built since its build path is incomplete. Cannot find the class file for java.awt.geom.Rectangle2D. Fix the build path then try building this project   

The type java.awt.geom.Rectangle2D cannot be resolved. It is indirectly referenced from required .class files   

I fixed that by including java.desktop in the module list, BUT that brought back the original 8 errors.

I'm not in a position to redo all of the module or classpath, only to fix the last conflict (Cannot find the class file for java.awt.geom.Rectangle2D.).

Any idea how to resolve that without breaking more things?

UPDATE: Screen Shots Of My BUILD PATH Dialogs

enter image description here

enter image description here

enter image description here


Edit:

I found the redundant jar by using Ctrl Shift T to open the type editor and the searching on that name.


2

There are 2 best solutions below

1
On

Again, I think the problem has to do with the newer versions of Java placing greater emphasis on Java 8++ "Modules.

Here's an example (Maven!]) project that I created without any regard to JPMS, and that works fine:

enter image description here

You'll notice that the ONLY thing that's NOT in "Classpath" is JRE 11.

enter image description here

The ONLY things in the [Module Dependencies] tab are from JRE 11. Conversely, there's NO JRE 11 stuff in the Classpath.

Hopefully, it will be fairly easy for you to organize your Eclipse "Java Build Path" to put what MUST go into "modules" ONLY in modules, and everything else in "Classpath".

'Hope that helps...

0
On

I found the redundant jar by using Ctrl Shift T to open the type editor and the searching on that name.