3

Short Version

What file do i have to delete from what folder to stop the error:

The package %s is accessible from more than one module: <unnamed>, %s

Long Version

When trying to build a Java web-site, i am getting the error:

The package %s is accessible from more than one module: <unnamed>, %s

For example:

enter image description here

  • The package org.w3c.dom is accessible from more than one module: \<unnamed\>, java.xml
  • The package javax.xml.parsers is accessible from more than one module: \<unnamed\>, java.xml
  • The package netscape.javascript is accessible from more than one module: \<unnamed\>, jdk.jsobject
  • The package org.xml.sax is accessible from more than one module: \<unnamed\>, java.xml

Now:

  • I don't know what a module is
  • and i don't know what a package is

But i do get get the sense that i need to delete a file (maybe a .jar file), or i need to edit a configuration file to remove a line, or i need to delete files elsewhere on my computer, or i need to delete environment variables.

  • i don't know what file to delete
  • i don't know what .jar file to delete
  • i don't know what text file to edit
  • i don't know what configuration file to edit
  • i don't know what line in what text file to add, edit, or remove

So, how do i:

Make package %s not accessible from more than one module


Apparently it is an bug added with Java 9 and the Java Platform Module System (JPMS), and it is not anything to do with Eclipse, NetBeans, or any IDE. It is a rule that was always there, but only Java 9 started enforcing it.

  • Some say you can disable the JPMS by deleting module-info.java
  • Others insist that you cannot disable JPMS at all after Java 8, and you just have to live on Java 8
  • Some have said that if you delete module-info.java it will get re-created

I don't have a module-info.java file anywhere in the folder or subfolders of the project

  • Others suggest it is an issue with classpath, or modulepath

Although i don't have a classpath or modulepath set:

>echo %classpath%
%classpath%

>echo %modulepath%
%modulepath%

>echo %java_home%
C:\Program Files\Java\jdk-18.0.1.1

IDE: Visual Studio Code

Project structure

The web-site is make up of a structure of files and folders. Some are probably there by convention, some are probably there by rule, and some may have been a dumping ground for extra stuff. I don't know which is which:

  • .vscode
  • build
  • conf
  • dist
  • JMeter
  • LibrarySourceCode
  • nbproject (deleted in an attempt to fix the issue)
  • sql
  • src
  • WebRoot
    • applets
    • META-INF
    • WEB-INF
      • classes
      • lib
        • activation.jar
        • cglib-full-2.0.2.jar
        • commons-beanutils.jar
        • commons-codec-1.3.jar
        • commons-collections-2.1.1.jar
        • commons-collections4-4.4.jar
        • commons-compress-1.20.jar
        • commons-dbcp-1.2.1.jar
        • commons-digester.jar
        • commons-fileupload.jar
        • commons-lang-1.0.1.jar
        • commons-logging-1.2.jar
        • commons-math3-3.6.1.jar
        • commons-pool-1.2.jar
        • commons-validator.jar
        • curvesapi-1.06.jar
        • dom.jar
        • dom4j-1.4.jar
        • ehcache-0.9.jar
        • hibernate2.jar
        • itext-1.4.jar
        • jakarta-oro.jar
        • jaxen-full.jar
        • jaxp-api.jar
        • jmf.jar
        • jstl.jar
        • jta.jar
        • log4j-1.2-api-2.17.1.jar
        • log4j-api-2.17.1.jar
        • log4j-core-2.17.1.jar
        • log4j-jcl-2.17.1.jar
        • mail.jar
        • odmg-3.0.jar
        • ooxml-schemas-1.1.jar
        • plugin.jar
        • poi-3.9-20121203.jar
        • poi-ooxml-3.9-20121203.jar
        • poi-ooxml-schemas-3.9-20121203.jar
        • sax.jar
        • saxpath.jar
        • sessionmon.jar
        • sqljdbc41.jar
        • standard.jar
        • struts.jar
        • xalan.jar
        • xercesImpl.jar
        • xml-apis.jar
        • xmlbeans-3.0.1.jar
        • xmlbeans-4.0.0.jar
        • xmlbeans-5.0.3.jar
      • tags
  • build.xml (deleted in an attempt to fix the issue)

Research Effort

That's a restriction by the Java Platform Module System (JPMS), not by Eclipse (so don't shoot the messenger). If you delete the file module-info.java in your default package (which disables JPMS) it should work with Java 9 or higher.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • What is the command line? – Johannes Kuhn Jun 29 '22 at 21:47
  • @JohannesKuhn *If* there is a way to see it: i don't know it. – Ian Boyd Jun 29 '22 at 22:10
  • What libraries/dependencies do you have in your project? – Johannes Kuhn Jun 29 '22 at 22:16
  • @JohannesKuhn While file or folder would i look at the find libraries? Which file or folder would i look at to find dependencies? – Ian Boyd Jun 29 '22 at 22:31
  • Anything that adds something to those packages. – Johannes Kuhn Jun 29 '22 at 22:34
  • What would be an example of **where** something would add anything to a package? Which file would you like me to dump the contents of? Which folder would you like me to dump to contents of? – Ian Boyd Jun 29 '22 at 22:40
  • Perhaps `build.xml`? I think that's an Ant file, which is a dependency management/build tool for Java (though I have no experience with it). – Slaw Jun 29 '22 at 22:43
  • @Slaw The `build.xml` referenced a file inside the folder `nbproject`. I deleted `build.xml` and the folder `nbproject` (see edited question above) and the errors still happen. – Ian Boyd Jun 29 '22 at 22:49
  • Sorry, I didn't mean delete that file. I was answering [your question](https://stackoverflow.com/questions/72807971/how-to-make-a-package-not-accessible-from-a-module-i-e-how-to-remove-a-package#comment128601721_72807971) towards @JohannesKuhn. – Slaw Jun 29 '22 at 22:50
  • @Slaw Well, it didn't break anything. It may have been leftover from Eclipse in 2005. – Ian Boyd Jun 29 '22 at 22:51
  • 1
    Might `WebRoot/WEB-INF/lib` be relevant? How about `WebRoot/META-INF`? – Ian Boyd Jun 29 '22 at 22:52
  • Yes. What libraries are in there? Names help, opening them with a zip program is better. – Johannes Kuhn Jun 29 '22 at 22:56
  • How do i know what libraries are in where? Which folder would you like a screenshot of? Which file would you like a screenshot of? The folder structure is in the question. – Ian Boyd Jun 29 '22 at 23:35
  • WebRoot/WEB-INF/lib – Johannes Kuhn Jun 29 '22 at 23:38
  • Added the list of files in the `WebRoot/WEB-INF/lib` folder to the question. – Ian Boyd Jun 30 '22 at 00:10
  • In short, you get that error if a jar on the classpath has classes in the same package as some module - I guess, from the jar file names, that `dom.jar` contains classes in `org.w3c.dom`, `jaxp-api` - `javax.xml.parsers`... Just open the files as zip archive, and look if they contain one of the reported package names as folder (with `.` treated as path separator). – Johannes Kuhn Jun 30 '22 at 00:22

0 Answers0