The Package Org.W3C.Dom Is Accessible from More Than One Module: <Unnamed>, Java.Xml

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

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

Eclipse is confused by imports ("accessible from more than one module")

This is caused by

  • a JAR on the Classpath that contains the package java.awt that also exists in the system library but the
  • JRE System Library is on the Modulepath

In the Java Platform Module System (JPMS) it is not allowed to use the same package in more than one module. If the Modulepath and the Classpath is used, everything on the Classpath is handled as the <unnamed> module (in your case the package java.awt exists in the system module java.desktop and also via the JAR on the Classpath in the module <unnamed>).

Since the JRE System Library cannot be moved from the Modulepath to the Classpath (see this answer by Stephan Herrmann for details), you only have the following options:

  • Set the compiler compliance to 1.8 (as you already mentioned)
  • Rebuilt the JAR to avoid Java system library package names inside the JAR (if reflection is used, additional code changes may be necessary):

    • If you have the source code, change the package names (e.g. change the package and subpackae java to java_util and javax to javax_util) and recreate the JAR
    • If you have only the .class files you have to decompile the .class files first


Related Topics



Leave a reply



Submit