Create Maven Projects with Java 11
Configuring OS Environments
Configuring Environments on Windows
- Add environment variable
JAVA_HOME={jdk11_path}
. - Add
%JAVA_HOME%\bin
to the environment variablepath
. - Verify Java version.
$ java -version
. - Restart IDE.
Note: After updating the JAVA_HOME
environment variable, you need to restart your IDE.
Configuring Maven Project pom.xml
By default your version of Maven might use an old version of the
maven-compiler-plugin
that is not compatible with Java 9 or later versions. To target Java 9 or later, you should at least use version 3.6.0 of themaven-compiler-plugin
and set themaven.compiler.release
property to the Java release you are targetting (e.g. 9, 10, 11, 12, etc.). [1]
<properties> |
or
<plugin> |
Configuring IDE
Configuring Java 11 for IntelliJ IDEA
- Open Project Settings (Ctrl + Shift + Alt + S) –> Project –> Project SDK: 11, Project language level: 11.
- Open Settings (Ctrl + Alt + S) –> Build, Execution, Deployment –> Compiler –> Java Compiler –> Project bytecode version: 11
Verification
Running test
$ mvn test |