Fork me on GitHub

Java 9 in JAVA_HOME

$ export JAVA_HOME=/path/to/jdk9
$ mvn test

Using JDK Deprecated Modules

Since Java 9 some modules previously bundled with the JDK are disabled by default.

Version 2.20.1 of the plugin added automatically “–add-modules” option to the command line of forked JVMs (unless already specified by user) in order to ease the transition of applications to Java 9.

From 2.21 onwards the plugin will not add that option: the recommended way of using those modules is to add explicit dependencies of the maintained versions of such libraries.

This is a reference of the versions which were bundled with Java 8:

Commons Annotations


JavaBeans Activation Framework


Java Transaction API




org.glassfish.jaxb:jaxb-runtime:2.3.0 (implementation)

JAX-WS (implementation)

The source code for each of these is maintained at

Java 9 in configuration of plugin

The plugin provides you with configuration parameter jvm which can point to path of executable Java in JDK, e.g.:


Now you can run the build with tests on the top of Java 9.

Maven Toolchains with JDK 9

This is an example on Windows to run unit tests with custom path to Toolchain (-t …).

$ mvn -t D:\.m2\toolchains.xml test

Without (-t …) the Toolchain should be located in ${user.home}/.m2/toolchains.xml.

The content of toolchains.xml would become as follows however multiple different JDKs can be specified.

<toolchains xmlns=""

Your POM should specify the plugin which activates only particular JDK in toolchains.xml which specifies version 9:


Now you can run the build with tests on the top of Java 9.