logo

How to compile Maven project with different Java version

Maven compiler plugin enables Maven to compile the project source with a particular Java version. Now I will tell Maven to use Java 1.6 to compile the project source code.

Which JDK version will Maven use to compile source of your project by default depends on Maven version. It used to be 1.4, right now it's 1.5, but usually you want to change it.

Maven compiler plugin enables Maven to compile the project source with a particular JDK version. Now I will tell Maven to use JDK 1.6 to compile the project source code:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

If you do a radical change like this, Eclipse will need to update Maven project. To do so, right click on project, choose Maven -> Update Project.


comments powered by Disqus

rss

Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects:
github

Search