For all of you who always forget, like myself, how to let maven handle the Java version in your projects via the pom.xml …

For Java 7 you use the following code snippet in your projects pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>2.5.1</version>
         <configuration>
            <source>1.7</source>
            <target>1.7</target>
         </configuration>
      </plugin>
   </plugins>
</build>

for an other version of Java you change the value in the source and target tags.


One Response to “Maven: How to set the Java Version in pom.xml”
  1. Der unbekannte Kumepl says:

    Mother of snippet.

  2.  
Leave a Reply

You must be logged in to post a comment. Login »