Can't get Maven to recognize Java 1.8
For me the issue was that when I installed from jdk-8u25-macosx-x64.dmg
the installation did not update the /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
directory link to the new 1.8 JDK. This may not have been the issue of the original question but it was the solution for me when I encountered the same error message.
I don't know why the installer doesn't link it and to make matters more confusing, the path is different depending on whether you installed it from Oracle or Apple. See Mac OS X 10.6.7 Java Path Current JDK confusing
I did the following to fix my environment
cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/<installed_jdk_version>.jdk/Contents CurrentJDK
It turns out that I had a forgotten ~/.mavenrc
file that had set the value of JAVA_HOME
.
For future readers, check the following locations for places that may override JAVA_HOME
(in ascending order of precedence):
~/.bash_profile
~/.bash_login
~/.bashrc
~/.profile
/etc/mavenrc
~/.mavenrc
The solution which worked for me:
In Eclipse, I had a wrong run configuration in my Maven build. Go to
Run Configurations -> JRE [Tab]
and set the runtime to Java 8.