Reputation: 2736
I have three applications I deploy with Java Web Start to clients. All three of these applications use JAXB. Under Java 1.9 to get the jaxb module loaded you have to use:
--add-modules java.xml.bind
Java Web Start let's you pass VM arguments to applications with the java-vm-args attribute of the java/j2se tag. However, only the arguments listed in the documentation are supported and --add-modules
is not in that list.
So the question is how do you pass "--add-modules java.xml.bind"
to the 1.9 VM when running code via Java Web Start that uses JAXB?
Here is what I tried and my testing shows that --add-modules is indeed not supported by the java-vm-arg attribute:
<resources>
<property name="jnlp.packEnabled" value="true"/>
<java version="9" java-vm-args="--add-modules java.xml.bind"/>
<java version="1.8+"/>
<jar href="redacted.jar"/>
</resources>
Upvotes: 4
Views: 1425
Reputation: 2736
Per the Modules Shared with Java EE Not Resolved by Default section of the Java 9 migration doc --add-modules
is a workaround because JAXB is being removed from the JDK in the future. So to solve this I just included the JAXB API and an implementation on my classpath, using ANT+Ivy this configuration got me what I needed:
<dependency org="org.glassfish.jaxb" name="jaxb-runtime" rev="2.3.0"/>
<dependency org="org.glassfish.jaxb" name="jaxb-core" rev="2.3.0"/>
<dependency org="javax.xml.bind" name="jaxb-api" rev="2.3.0"/>
<dependency org="javax.activation" name="activation" rev="1.1.1"/>
A few transitive dependencies came along with it (FastInfoset, istack-commons, stax-ex, and txw2). These are desktop swing applications so I like keeping the jar file as small as feasible, after pack200 compression it only added about 600K to my fat jar.
The glassfish implementation does result in an illegal reflective access warning from Java 9. I assume an update will come out soon that doesn't use illegal reflection.
Upvotes: 2
Reputation: 31978
Referring the same documentation, you should change to using version equal to 9
or 9+
(ea builds) as:
<resources>
<property name="jnlp.packEnabled" value="true"/>
<j2se version="9" java-vm-args="--add-modules java.xml.bind"/>
<j2se version="1.8+"/>
<jar href="redacted.jar"/>
</resources>
The version attribute refers, by default, to a platform version (specification version) of the Java Platform Standard Edition. Currently defined platform versions are 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, and 9. (A platform version does not usually contain a micro version number; for example 1.4.2.)
I've also made this and that answer previously to explain on a permanent solution instead of making such temporary fixes to the code relying on java.xml.bind
which is deprecated.
Upvotes: 0
Reputation: 5449
Use an equals rather than a space. Also the module name is "java.xml.bind". This gives you java-vm-args="--add-modules=java.xml.bind"
.
Upvotes: 1