简体   繁体   中英

Specific question concerning "The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml"

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?

您不需要反编译/重新编译任何东西,您只需删除该包对应的 JAR 文件中的目录即可。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM