Reputation: 125
So I have a small JAR application (not running in a web container) that uses some javax.* classes of JAXB running on jdk8. The time has come to upgrade to jdk17 which does not ship with JAXB. So I thought,easy enough, I download the jakarta ee 9 (or 10) reference implementation jar files for JAXB, switch in the code javax.* to jakarta.* namespace and we are good to go. Seems I can't find where I can download the reference implementation jar files for JAXB in jakarta ee 9 (or 10). So obviously I'm missing something. Can someone guide me to the good approach to solve this ?
Upvotes: 2
Views: 28203
Reputation: 68
This is not directly related to the question, but it can be helpful for people who wants to update package names javax
to jakarta
. If you have huge project contains lots of classes, then it will be really boring to convert them with replacer. Instead, you have 2 options:
Execute shell script in your project root folder and let the script converts automatically for you. However, you have to modify the shell script to cover all the packages.
You can find the script in this article.
If you are using Intellij IDEA, then you are lucky, there is a button to convert all packages.
Refactor > Migrate Packages and Classes > Java EE to Jakarta EE
Follow the above path to find the option.
Upvotes: 0
Reputation: 2197
I mostly use maven to handle my dependencies but hope this helps at least a bit.
For jaxb 3.x you can use following api-dependency
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.1</version>
</dependency>
Then for implementation you can use the following.
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>3.0.0</version>
</dependency>
If you need to generate classes from xsd you can use jaxb2-maven-plugin 3.1.0. It seems to only depend on jakarta.xml.bind-api while including rest as nested dependencies.
<!--
by default searches schemas from src/main/xsd
and binding files from src/main/xjb
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.example.api</packageName>
</configuration>
</plugin>
Not sure about javax.activation
Upvotes: 2