Home >Java >javaTutorial >How to Resolve the `javax.xml.bind` Issue in Java 11?

How to Resolve the `javax.xml.bind` Issue in Java 11?

Susan Sarandon
Susan SarandonOriginal
2024-11-06 00:20:02776browse

How to Resolve the `javax.xml.bind` Issue in Java 11?

javax.xml.bind problem in Java 11

How to solve the problem that javax.xml.bind package does not exist in Java 11?

According to the release documentation, Java 11 has removed Java EE modules:

  • java.xml.bind (JAXB) - Removed

Passed This problem can be solved by using an alternative version of Java EE technology. Just add the Maven dependencies containing the required classes:

<code class="xml"><dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.3.0</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-core</artifactId>
  <version>2.3.0</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.3.0</version>
</dependency></code>

Jakarta EE 8 Update (March 2020)

It is possible to use Jakarta EE 8 Jakarta XML Binding in instead of the old JAXB module:

<code class="xml"><dependency>
  <groupId>jakarta.xml.bind</groupId>
  <artifactId>jakarta.xml.bind-api</artifactId>
  <version>2.3.3</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.3.3</version>
  <scope>runtime</scope>
</dependency></code>

Jakarta EE 9 Update (November 2020)

Using Jakarta XML Binding 3.0 Latest version:

  • Jakarta EE 9 API jakarta.xml.bind-api
  • compatible implementation jaxb-impl
<code class="xml"><dependency>
  <groupId>jakarta.xml.bind</groupId>
  <artifactId>jakarta.xml.bind-api</artifactId>
  <version>3.0.0</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>3.0.0</version>
  <scope>runtime</scope>
</dependency></code>

Note: Jakarta EE 9 adopts the new API package namespace jakarta.xml.bind.*, so please update the import statement:

javax.xml.bind -> jakarta.xml.bind

Jakarta EE 10 Update (2022-6 Month)

Use the latest version of Jakarta XML Binding 4.0 (requires Java SE 11 or higher):

  • Jakarta EE 10 API jakarta.xml.bind-api
  • Compatible implementation of jaxb-impl
<code class="xml"><dependency>
  <groupId>jakarta.xml.bind</groupId>
  <artifactId>jakarta.xml.bind-api</artifactId>
  <version>4.0.0</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>4.0.0</version>
  <scope>runtime</scope>
</dependency></code>

The above is the detailed content of How to Resolve the `javax.xml.bind` Issue in Java 11?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn