How to specify Java version in Spring pom.xml

Since version 9, Java has new features every 6 months and it’s very hard to keep track of these new changes. If you’re thinking about migrating to a specific Java version is recommended to make a complete diff of APIs between selected Java versions.

What is the latest Java version?

As of February 2022, Java 17 is the latest released Java version. It is also the next long-term support version (LTS) after Java 11.

Is Java 8 and Java 1.8 the same?

In short – 8 is product version number and 1.8 is the developer version number (or internal version number).

What version should I use in my project?

The correct way is to use the followings values in java.version for different Java versions:

Java 8 : 1.8 or 8
Java 9 : 9
Java 10 : 10
Java 11 : 11

Java 17 : 17

So for Java 11 , it should be:

<properties>
   <java.version>11</java.version>
</properties>


<properties>
    <java.version>11</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
</properties>

From the maven-compiler-plugin docs, maven.compiler.source and maven.compiler.target are the user property for the source and target config parameters.

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *