4

I have a weird problem with an import I'm using in an Eclipse project. I am importing javax.xml.bind but I have an error saying that it cannot be resolved. My project's compliance is using Java 1.8, my JRE System Library is also 1.8. A friend of mine that is working on the code with me through Github has the same Java configurations in Eclipse but he is not having the same problem as I do. We have tried uninstalling and re installing the JRE for the project and still won't work. Does anyone know what's this all about?

Galo
  • 43
  • 1
  • 1
  • 4

2 Answers2

11

You might have configured a newer Java JDK/JRE (where javax.xml.bind is missing) in Window > Preferences: Java > Installed JREs.

Since Java 11 javax.xml.bind is not contained anymore in the system library and has to be added as a dependency (e.g. with this one).

howlger
  • 31,050
  • 11
  • 59
  • 99
  • What the solution add another version of JDK/JRE? – Jon Jan 15 '21 at 22:51
  • 4
    @Jon Since Java 11 `javax.xml.bind` is not contained anymore in the system library and has to be added as dependency (e.g. [with this one](https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api)). – howlger Jan 17 '21 at 14:44
  • @howlger, your comment would really improve your answer, imho. – Bernat May 13 '22 at 14:18
1

I'm working with Java 17. As mentioned javax.xml.bind is missing in newer JDKs.

Step 1: Go to this link .

Step 2: Select one of the Versions

Step 3: Copy the contents of dependency tag under Maven tab.

Step 4: Add the copied contents in pom.xml file within <dependencies> </dependencies> tags

Now you should be able to see an option to import required libraries.