0

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.


Omid
  • 5,823
  • 4
  • 41
  • 50
Steve
  • 3,127
  • 14
  • 56
  • 96
  • Q: Is this a typo: `javax.mal.stream`? ALSO: are you using JPMS? See [Eclipse is confused by imports “accessible from more than one module”](https://stackoverflow.com/questions/55571046/) – paulsm4 Dec 26 '19 at 17:51
  • 1. Not a typo. 2. I don't know, the project is huge. I would guess so given what Conifigur Buildpath > Modules looks like. 3. Thanks for the link I am checking it out. – Steve Dec 26 '19 at 18:00
  • I read the SO post you pointed to. I already read it, the paltry understanding I have comes from there. We aren't using maven, at least directly, so I can't use some of the advice there. I've been using the GUI in Eclipse attached to "Configure Build Path". The project is huge and we do not saw off little pieces of it so I don't think we care much about the modules. – Steve Dec 26 '19 at 18:05
  • No, no, no. 1) The main point of the thread is that "JPMS" might somehow be the culprit here (not "Maven"). 2) So what is `javax.mal`, if not a typo? I'm not familiar with it :( ADDITIONAL SUGGESTIONS:3) Please consider installing Java8, 9 and 11 runtimes; setting your compile target to Java 8, 9 and 11, and see if you find a "breaking version". 4) Please double-check that *you're* not somehow introducing JPMS ("module" dependencies. – paulsm4 Dec 26 '19 at 20:51
  • Sorry about the typo, I misunderstood the string you were talking about. I fixed the typo. – Steve Dec 26 '19 at 20:58
  • ALSO: Eclipse > your-project > Build Path > Java Build Path > Module Dependencies. You *SHOULD* have a "Module Dependencies" tab. Ideally, it should be EMPTY. If it's *NOT* empty, then there *MUST NOT BE* any conflicts/overlaps between [Libraries] and [Module Dependencies] – paulsm4 Dec 26 '19 at 20:58
  • I didn't install multiple runtimes. I did go to Build Path > Configure Buildpath > Compiler compliance. Starting with Java 8 - no problems. The error messages come back with Java 9 – Steve Dec 26 '19 at 21:06
  • Ugh. My "Module Dependencies" tab has many, many entries in it. – Steve Dec 26 '19 at 21:07

2 Answers2

0

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...

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • Thanks for the screenshots. I updated my post with similar screen shots. My classpath has some javax.xml packages in it, but the remove button is greyed out. – Steve Dec 30 '19 at 16:02
0

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

Steve
  • 3,127
  • 14
  • 56
  • 96