Set java compiler version in pom

Suppose you write a project that must have mandatory support for java 1.6 and higher, but you only have java 9 installed  and also want the compiled classes to be compatible with JVM 1.8.

The javac  compiler can accept certain commands -source  and -target  to specify the version of java used in your project
and the version of java for the target assembly.

You can add the following two properties to your pom.xml:

or you can configure maven compiler plugin directly with same options:

 

Related Post

Leave a Reply

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