4

I've researched this for days and it appears that all the answers are specific to Eclipse. I'm experiencing this error on Visual Studio Code:

The package javax.xml.bind.annotation is accessible from more than one module: <unnamed>, java.xml.bind

This appears on the lines containing javax.xml.bind.annotation imports.

Using:

  • Java 11.0.4
  • VSCode 1.43.2
  • Java Extension Pack 0.9.0

Gradle builds without issues, so the error message indicates some kind of disconnect between the terminal and VSCode.


So far, I have:

  • Made sure JAVA_HOME and java.home match
  • Cleaned the Java language server workspace
  • Made sure java.import.gradle.home` is set properly
  • Disabled the java.import.gradle.wrapper
  • Run a full gradle clean build on the project
  • Done extensive internet searches

Any help would be appreciated, thank you for your time!

Edit

I'm aware of this question, but there was never an answer for it.

retrovius
  • 782
  • 1
  • 10
  • 25

1 Answers1

-1

In the Java Platform Module System (JPMS) it is not allowed to use the same package name in more than one module. If the Modulepath and the Classpath is used, everything on the Classpath is handled as the module. JRE Systeme Library is on the Modulepath as contains the 'java.xml.bind', so, your Classpath contains a package named 'java.xml.bind' too, as the .

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

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • 1
    I've seen that in answers as well. That doesn't give me a solution, however. I don't have a `module-info.java` file anywhere in my project, so I don't see a Modulepath at all. I need the `java.xml.bind` dependency, so is there a way to reconcile this collision? – retrovius Apr 22 '20 at 18:02
  • 1
    as the 'javax.xml.bind.annotation' package had been removed from jdk11, so, you had referenced this package in two ways, in a module and in the classpath, find it out, and remove one dependence. – Steven-MSFT Apr 23 '20 at 02:42
  • 1
    I'm sure you're right, but why does the `gradle build` work without an error? My issue is there is a disconnect between the terminal and VSCode. – retrovius Apr 28 '20 at 16:05