Skip to content
No description, website, or topics provided.
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
executable Remove redundant source/target settings Apr 6, 2017
mavenrc Remove redundant source/target settings Apr 6, 2017
toolchain
.gitignore
LICENSE
README.md

README.md

Maven Java 9

Different ways to build projects on Java 9 with Maven. The goal is to be able to simply run mvn clean install and then launch the resulting JAR with java -jar target/demo-java-9.jar.

Some approaches are more intrusive, others more brittle - have a look at the individual solutions for a small discussion of its pros and cons.

💥 Compiler Arguments 💥

In case you're trying to use some of the new command line options like --add-modules, be aware that the following doesn't work:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.6.1</version>
	<configuration>
		<compilerArgs>
			<arg>--add-modules java.xml.bind</arg>
		</compilerArgs>
		<fork>true</fork>
	</configuration>
</plugin>

With this configuration I got errors like the following:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] javac: invalid flag: --add-modules java.xml.bind
Usage: javac <options> <source files>
use --help for a list of possible options

Apparently it's common knowledge that <arg> will put arguments that contain a space into quotes before passing them, so I had to do the following instead:

<compilerArgs>
	<arg>--add-modules</arg><arg>java.xml.bind</arg>
</compilerArgs>

Obvious, right? 🤔

You can’t perform that action at this time.