How to indicate the java compiler version and target version
Saturday, May 3rd, 2008By default, the maven will use the compiler source check level to 1.3 and target version to 1.1 for maximum artifact compatibility. However, in most of your project, you don’t need such compatibility. In contrast, you will want to use more recently language features: like assertion, generic type of container, and so on. You can do that be indicate the compiler source and target requirement.
First, from Eclipse IDE, select “maven – add plugin”, add the maven-compiler-plugin, the lastest version should be 2.02. This will add some elements to you pom.xml like:
...
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
</plugins>
</build>
...
you can add attibutes after version, like:
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
This will set the source check and target check version to jre 6.0. You will notice that although sun has change this naming scheme from 1.x to x.0 from jre 5.0 on, but maven still using 1.x scheme.
