Java 11 package javax.xml.bind does not exist
If you are seeing the error "package javax.xml.bind does not exist" in your Java 11 project, it means that the Java XML Bind (JAXB) API is not included in the classpath.
In Java 11, the JAXB API was removed from the JDK and is now available as a separate module. To use JAXB in your project, you will need to include the java.xml.bind
module in your dependencies and add it to the classpath.
If you are using a dependency management tool such as Maven or Gradle, you can add the java.xml.bind
module as a dependency in your pom.xml
or build.gradle
file. For example, in Maven you can add the following dependency:
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
In Gradle, you can add the following dependency:
dependencies {
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
}
Note that the package name for the JAXB API has changed in Java 11 from javax.xml.bind
to jakarta.xml.bind
. You will need to use the new package name in your code.
Once you have added the java.xml.bind
module as a dependency, you should be able to use the JAXB API in your project without encountering the "package javax.xml.bind does not exist" error.