"javac -version" throws Unsupported major.minor version 52.0, are my symlinks wrong?
They are in mine /usr/bin
:
lrwxr-xr-x 1 root wheel 73 Aug 21 18:18 javap -> /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/javap
lrwxr-xr-x 1 root wheel 73 Aug 21 18:18 javah -> /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/javah
lrwxr-xr-x 1 root wheel 82 Aug 21 18:18 javafxpackager -> /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/javafxpackager
lrwxr-xr-x 1 root wheel 75 Aug 21 18:18 javadoc -> /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/javadoc
lrwxr-xr-x 1 root wheel 73 Aug 21 18:18 javac -> /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/javac
lrwxr-xr-x 1 root wheel 72 Aug 21 18:18 java -> /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java
which all point to JDK v1.7.x.
I am running Max OS X 10.9.4. I was foolishly trying to downgrade from 1.8 to 1.7 which caused these problems. Trying to run javac -version
will throw this stack trace:
zhickman:bin zhickman$ javac -version
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
However, running java -version
gives me:
zhickman:bin zhickman$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
I think I updated my symlinks incorrectly. I understand that the error "Unsupported major.minor version ..." is common, but I've only seen solutions that include compiled code trying to run, which is causing this problem.
Additional Notes:
zhickman:bin zhickman$ $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
source to share
I am using both Java 8 and Java 7. This error i.e. Unsupported major.minor version 52.0
arises for me sometimes changing from Java 8 to Java 7. I am using eclipse on Windows. I noticed that when moving from Java 8 to Java 7, you also need to change the Java compiler mapping from 1.8 to 1.7. This resolves the error. I don't know much about Mac OS X, but if you can change the compiler mapping from 1.8 to 1.7 it will fix the error.
source to share