I'm building my project with maven and java-9. I've added in my pom.xml
file:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>--add-modules</arg>
<arg>java.xml.bind</arg>
</compilerArgs>
</configuration>
</plugin>
But still, to run the application I have to run it like this:
java -jar --add-modules java.xml.bind my-app.jar
Is there a way to build the application, to run from the command line without --add-modules java.xml.bind
to java command line arguments?
I made this answer a while ago where I answered this as an additional info to exposing non
java.se
packages in Java-9 using Maven.The added part specifically focusses on using the standalone version of the
java.xml.*
APIs. To adapt to which you can probably start consuming the dependency onjaxb-api:2.3.0
which can be loaded as a module and can be executed from the classpath as well. The change you need to make is to add the following to your dependencies list:This way you ensure migrating to standalone APIs for the module as well as moving away from a deprecated piece of code.