Maven uses JRE7 instead of JDK?
To configure maven builds to use the correct java execution environment you need to change the execution environment used by Maven.
1. JRE Locations
To set up JRE locations load the preferences window under Window\Prefences (Windows) or Eclipse\Preferences(OSX) or Edit\Preferences (Linux).
Expand the Java/Installed JREs option Select the JDK of choice, or Add one if not configured.
2. Map Execution Environments
To map any java version to a particular installed JRE select the Java/Installed JREs/Execution environment menu item
Select the appropriate default JRE installation for that version.
3. Run Configurations
If you have particular run configurations, you can change/create specific run configurations and link a specific execution environment just to that command.
- To do that select Run/Run Configurations
- Select or create the run configuration.
- Select the Execution Environment tab.
- Select the appropriate execution environment for this command.
You should verify that the Maven "run configurations..." is connected to the correct JRE. If the project JRE is correct but the run configuration JRE is incorrect you will get this error. To fix, go Under Maven Build, choose the JRE tab.
Maven 2.0.9+ supports toolchains that allows you can declare the version of the JDK required for the build.
Excerpt from the related Maven mini-guide:
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.5</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
...
</plugins>
You need to set your JAVA_HOME environment variable to the JDK directory.
EDIT:
In your installed JREs preferences window in Eclipse remove the JRE and select the JDK. Also make sure that your project is set to use that JRE library (Right-click on the "JRE System Library" under your maven project structure in the explorer and set it as the "Execution Environment")