Java Mac OS X El Capitan 上不支持的 Major.minor 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34201990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unsupported major.minor version on Mac OS X El Capitan
提问by Bowersbros
Following the solutions online for Major Minor version of Java being incorrect on El Capitan, I saw several solutions which made you either disable rootless, which i didn't like the sound of, or just didn't work anymore in OS X El Capitan.
在 El Capitan 上针对 Java 的主要次要版本不正确的在线解决方案之后,我看到了几个解决方案,它们使您要么禁用 rootless,我不喜欢它的声音,要么在 OS X El Capitan 中不再工作。
采纳答案by Bowersbros
When trying to run webdriver-manager start
on El Capitan, you may get an error saying:
尝试webdriver-manager start
在 El Capitan上运行时,您可能会收到一条错误消息:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncher : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.accessexport JAVA_HOME="$(/usr/libexec/java_home --version 1.8)"
0(URLClassLoader.java:58)
at java.net.URLClassLoader.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Selenium Standalone has exited with code 1
The recommended fix for this online is to change the symlink that Mac OS X has to Java, which you can find by running echo $JAVA_HOME
in the terminal.
推荐的在线修复方法是将 Mac OS X 的符号链接更改为 Java,您可以通过echo $JAVA_HOME
在终端中运行来找到该符号链接。
This is pointing to the incorrect folder, and the error is because the application was compiled with a higher version of JRE than the machine is running in the terminal.
这是指向不正确的文件夹,错误是因为应用程序是用比机器在终端中运行的更高版本的 JRE 编译的。
You should go to Oracle, and download the latest JRE version (http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
您应该去 Oracle,并下载最新的 JRE 版本 ( http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
After this has been installed, you will have Java 8 on your machine, but it will not update the terminal properly. If you run java -version
in your terminal, you'll see Java Version "1.6"
, you want this to say Java Version "1.8"
. The previous way to do this was to change the symlink manually, however, since El Capitan, Apple have made certain folders unchangable even to admin users, with their Rootless install. This includes the /usr folder.
安装完成后,您的机器上将安装 Java 8,但它不会正确更新终端。如果你java -version
在你的终端中运行,你会看到Java Version "1.6"
,你想要这样说Java Version "1.8"
。以前的方法是手动更改符号链接,但是,自从 El Capitan 以来,Apple 已经通过 Rootless 安装使某些文件夹即使对管理员用户也无法更改。这包括 /usr 文件夹。
There are two ways to fix this, the first is dangerous, and what everyone else seems to recommend. The second, is safer, and what I am putting here.
有两种方法可以解决这个问题,第一种是危险的,其他人似乎都推荐这种方法。第二,更安全,我在这里放的是什么。
If you go to your System Preferences -> Java -> Java -> View... -> System
and copy the Path field.
如果你去你的System Preferences -> Java -> Java -> View... -> System
并复制路径字段。
It will look something similar to the following:
它看起来类似于以下内容:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
We want most of this path, except the /bin/java
on the end.
我们想要这条路径的大部分,除了/bin/java
最后。
So your path should now be copied as:
所以你的路径现在应该被复制为:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Run the following command in the terminal, replacing [PATH] with the path you have from above.
在终端中运行以下命令,用上面的路径替换 [PATH]。
export JAVA_HOME="[PATH]"
export JAVA_HOME="[PATH]"
and run that in the terminal.
并在终端中运行它。
Afterwards, run java -version
again, and it should now say Java Version "1.8"
之后,java -version
再次运行,它现在应该说Java Version "1.8"
Now, webdriver-manager start
should succeed.
现在,webdriver-manager start
应该成功了。
回答by Sindhu Shree
Adding the following line to ~/.bash_profile worked for me:
将以下行添加到 ~/.bash_profile 对我有用:
. ~/.bash_profile
You might have to restart your shell for these changes to reflect or just run:
您可能需要重新启动 shell 才能反映或运行这些更改:
##代码##