How to specify Java version in Spring pom.xml

ads

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.

ads
Get our hottest stories to your inbox.
Check your inbox for a confirmation email.

Have something to add to this story? Share it in the comments.

Have something to add to this story? Share it in the comments.

Leave a Reply

Your email address will not be published.