W3docs

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.

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. To use JAXB in your project, you will need to add the JAXB API and its runtime implementation as dependencies.

If you are using a dependency management tool such as Maven or Gradle, you can add the JAXB dependencies to your pom.xml or build.gradle file. For example, in Maven you can add the following dependencies:


<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.1</version>
</dependency>

In Gradle, you can add the following dependencies:


dependencies {
    implementation 'javax.xml.bind:jaxb-api:2.3.1'
    implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.1'
}

For Java 11, the package name remains javax.xml.bind. You will need to use this package name in your code.

Once you have added the JAXB dependencies, you should be able to use the API in your project without encountering the "package javax.xml.bind does not exist" error.