I\'m new to maven, and also to MacOS.
I have setup maven in my terminal, and when getting the version settings (using mvn -v
) it seems it uses JDK 1.6,
You can also explicitly tell maven which java version to compile for. You can try adding the maven-compiler-plugin
to your pom.
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
If you imported a maven project into an IDE, then there is probably a maven setting in your IDE for default compiler that your maven runner is using.
Get into
/System/Library/Frameworks/JavaVM.framework/Versions
and update the CurrentJDK
symbolic link to point to
/Library/Java/JavaVirtualMachines/YOUR_JDK_VERSION/Contents/
E.g.
cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/ CurrentJDK
Now it shall work immediately.
For Eclipse Users. If you have a Run Configuration that does clean package for example.
In the Run Configuration panel there is a JRE tab where you can specify against which runtime it should run. Note that this configuration overrides whatever is in the pom.xml.