这些在我的/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
都指向JDK v1.7.x。
我正在运行Max OS X 10.9.4。我愚蠢地试图从1.8降级到1.7,这导致了这些问题。尝试运行javac -version
会抛出此堆栈跟踪:
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)
但是,运行java -version
会给我:
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)
我认为我已经错误地更新了我的符号链接。我理解"不支持的major.minor版本......"错误很常见,但我只看到涉及尝试运行导致此问题的编译代码的解决方案。
额外说明:
zhickman:bin zhickman$ $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
答案 0 :(得分:3)
事实证明我需要移除/Library/Java/Extensions
,其中包含我假设引用JRE8的tools.jar
。
答案 1 :(得分:0)
我同时使用Java 8和Java 7.这个错误即。我有时会在从Java 8更改为Java 7时出现Unsupported major.minor version 52.0
。我在Windows中使用eclipse。我观察到的是,当您从Java 8降级到Java 7时,您还必须将Java编译器合规性从1.8更改为1.7。这解决了错误。
我对Mac OS X了解不多,但如果您可以将编译器合规性从1.8更改为1.7,它将修复错误。