Why Maven uses JDK 1.6 but my java -version is 1.7 Why Maven uses JDK 1.6 but my java -version is 1.7 linux linux

Why Maven uses JDK 1.6 but my java -version is 1.7


add the following to your ~/.mavenrc:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/{jdk-version}/Contents/Home

Second Solution:

echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile


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/Versionssudo rm CurrentJDKsudo ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/ CurrentJDK

Now it shall work immediately.


You can also do,

<properties>      ...        <!-- maven-compiler-plugin , aka JAVA Compiler 1.7 -->      <maven.compiler.target>1.7</maven.compiler.target>      <maven.compiler.source>1.7</maven.compiler.source>      ...  </properties>