2

I'm in the process of migrating my companies projects from Java 1.8 to OpenJDK 14. Like multiple other people (fe. in this, this or this thread) I've run into some troubles with Java 9 Modularity, specifically with the package org.w3c.dom.

I have already generated the module-info.java and currently both the JRE System Library (OpenJDK 14) and all external JARs are on the Modulepath in the Java Build Path. So I no longer have the error module: <unnamed>. The actual compile error I get right now is:

The package org.w3c.dom is accessible from more than one module: batik.all, java.xml, xml.apis.ext

BTW I can't just simply delete the JARs batik.all and xml.apis.ext, since other packages of those are used in the project which are not in the JavaSE.

I've also been told by my supervisors to not convert any non-maven projects to maven projects, which I mention since all other references I find to this problem seem to discuss the solution of utilising Maven Dependencies and Excludes.

Now after some analysis I've come to the conclusion that the most effective way for me to get rid of these errors would be to unpack the two JAR files, decompile the packages, delete the duplicate org.w3c.dom from those external JARs and finally recompile the whole thing and pass that custom JAR to the build path.

  1. Does that idea make sense? Would you do it this way if you couldn't use Maven dependencies?
  2. Since we're migrating from 1.8, I've never actually used module-info.java, so perhaps there's a way simpler way of excluding those packages in that file? I'm open for alternative solutions!
  3. Last but not least, if my described solution is the way to go, what would be the best way to unpack and repack those JAR files?
yur
  • 380
  • 2
  • 15

1 Answers1

1

You do not need to decompile/recompile anything, you can simply delete the directory in the JAR file corresponding to the package.

spongebob
  • 8,370
  • 15
  • 50
  • 83