So I am having pretty much the exact same problem as this guy:
Maven Installation OSX Error Unsupported major.minor version 51.0
Nothing in there is working for me....I think the problem is in my symlinks somewhere. I'de defined $JAVA_HOME in .bash_profile and java -version correctly reports the version. However, for some reason, mvn is trying to use an old version of java.
Here's a list of everything on my machine:
/usr/libexec/java_home -verbose
Matching Java Virtual Machines (5):
1.8.0_40, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
1.7.0_79, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
1.7.0_75, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-466.1, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
I want to be using 1.8. And mvn to recognize it.
If I run this:
ls -l `which java`
lrwxr-xr-x 1 root wheel 74 May 24 22:46 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
And then if I run:
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
I do notice this symlink out of order:
cd /System/Library/Frameworks/JavaVM.framework/Versions
ls -l
total 64
lrwxr-xr-x 1 root wheel 10 May 24 22:46 1.4 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 May 24 22:46 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 May 24 22:46 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 May 24 22:46 1.5.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 May 24 22:46 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 May 24 22:46 1.6.0 -> CurrentJDK
drwxr-xr-x 7 root wheel 238 May 24 22:46 A
lrwxr-xr-x 1 root wheel 1 May 24 22:46 Current -> A
lrwxr-xr-x 1 root wheel 59 May 24 22:46 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
Is "CurrentJDK" actually used anywhere? And how do I update the link?
I can't understand whats going on...everything seems to be pointed to the new Java, where and how is mvn reading Java 6 (Unsupported major.minor version 51.0)?