Historically, I always used the following JAXB RI artifacts in my Maven projects:
com.sun.xml.bind:jaxb-impl
- Runtimecom.sun.xml.bind:jaxb-xjc
- Schema compilercom.sun.xml.bind:jaxb-jxc
- Schema generatorSince approximately version 2.2.10*
these artifacts are now described as "old":
com.sun.xml.bind:jaxb-impl
Old JAXB Runtime module.
So it looks like these artifacts are now obsolete.
The question is:
Which artifacts should be used instead?
JavaTM Architecture for XML Binding (JAXB) provides an API and tools that automate the mapping between XML documents and Java objects. JAXB makes XML easy to use by compiling an XML schema into one or more Java technology classes.
com.sun.xml.bind » jaxb-xjcEDL. Old JAXB Binding Compiler. Contains source code needed for binding customization files into java sources. In other words: the *tool* to generate java classes for the given xml representation. Last Release on Jun 6, 2022.
org.glassfish.jaxb » xsomEDL. XML Schema Object Model (XSOM) is a Java library that allows applications to easily parse XML Schema documents and inspect information in them. It is expected to be useful for applications that need to take XML Schema as an input.
After clarification with Oracle, the following artifacts should be used:
If you want to unmarshal XML to Java objects or marshal Java objects as XML:
<dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>...</version> </dependency>
If you have an XML Schema and want to generate the Java code out of it:
<dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-xjc</artifactId> <version>...</version> </dependency>
schemagen
)If you have Java classes with JAXB annotations and want to generate a XML Schema based on them:
<dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-jxc</artifactId> <version>...</version> </dependency>
The two latter artifacts (org.glassfish.jaxb:jaxb-xjc
and org.glassfish.jaxb:jaxb-jxc
) are wrapped by Maven plugins so you normally would not need them in the runtime.
If your Maven projects somehow don't get the full classpath, turn on debug output and check the Maven console. You might be seeing the following error message there:
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} @
This is due to the following problem:
Maven not picking JAVA_HOME correctly
The solution by @rustyx is to add -vm
option to the eclipse.ini
:
-vm <PATH_TO_JDK>\jre\bin\javaw.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With