I downloaded JAXB 2.3.0.1 and JavaBeans Activation Framework (JAF) 1.2.0 (based on the answer to this question). I extracted all JAR files to the same directory, then run the following command within that directory:
java -cp jaxb-api.jar;jaxb-core.jar;jaxb-impl.jar;javax.activation-1.2.0.jar
-jar jaxb-xjc.jar [xjc-arguments]
The above command fails with the following message:
java.lang.NoClassDefFoundError: javax/activation/DataSource
...
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
I have verified that class exists within the javax.activation-1.2.0.jar file. I have also tried using the new (to Java 9+) arguments -p . --add-modules java.activation
, but that fails with the following error message:
Error occurred during initialization of boot layer
java.lang.modules.ResolutionException: Modules jaxb.core and jaxb.impl export package com.sun.xml.bind.marshaller to module java.activation
If I try a combination of -cp
and --add-modules
, I get a different boot layer initialization error. Does anyone know how to get XJC to run using a Java 9+ platform?
My specific use case is OpenJDK 11 on Windows.
The primary issue was that the java executable doesn't support specifying both the -cp
and -jar
command-line arguments at the same time. Thanks to Alan Bateman for that information!
Therefore, the correct way to get this to work is by using the following command:
java -cp javax.activation-1.2.0.jar;jaxb-xjc.jar com.sun.tools.xjc.XJCFacade
[xjc-arguments]
In order to simplify running XJC, open bin/xjc.bat (extracted from jaxb-ri-2.3.0.zip), and edit the command line to match the above call.