By default, Maven uses the JDK that you run it with to compile your sources. To change the default version of Java that is selected on your machine, please see the specific instructions for your platform. Check with from a command line prompt.
Windows - use the Java Control Panel
Linux - use the command. More information can be found here
OSX - run Applications, Utilities, Java Preferences. Making changes to soft links by hand is error prone and can produce cryptic errors.
If you would like to enforce a particular JDK version or version range, add these parameters to your plugin's POM file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-java</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireJavaVersion> <version>[1.4,1.5)</version> </requireJavaVersion> </rules> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
Plugins are pre-configured to use Java 1.5 as the source level when compiling. If you would like to use a different source level, you'll need to set the property:
1 2 3 4 5 6 7 8
<project> ... <properties> ... <jdkLevel>1.4</jdkLevel> </properties> ... </project>
This property is also used by the Maven IDEA plugin to set the source level for the project generated when you run .