在 OS X 10.9 (Mavericks) 上安装 Java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19533528/
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
Installing Java on OS X 10.9 (Mavericks)
提问by user2909913
I have installed the JDKon Mac OS X v10.8(Mountain Lion). When I upgraded it to Mac OS X v10.9(Mavericks) and ran java -version
in the terminal, it showed:
我已经在Mac OS X v10.8(Mountain Lion)上安装了JDK。当我将其升级到Mac OS X v10.9(Mavericks) 并在终端中运行时,它显示:java -version
No Java runtime present, requesting install.
不存在 Java 运行时,请求安装。
Then I manually installed the JDK (1.7) on my Mac. It seems that the installation worked fine. When the installation was done, I opened the terminal and typed java -version
as well. It also showed the same error:
然后我在我的 Mac 上手动安装了 JDK (1.7)。似乎安装工作正常。安装完成后,我打开终端并输入java -version
。它也显示了同样的错误:
No Java runtime present, requesting install.
不存在 Java 运行时,请求安装。
How can I solve this problem?
我怎么解决这个问题?
采纳答案by Guy
The new Mavericks(10.9) showed me the "Requesting install", but nothing happened.
新的小牛队(10.9) 向我展示了“请求安装”,但什么也没发生。
The solution was to manually download and install the official Java package for OS X, which is in Java for OS X 2013-005.
解决方案是手动下载并安装 OS X 的官方 Java 包,该包位于 适用于 OS X 的 Java 2013-005.
Update:As mentioned in the comments below, there is a newer version of this same package:
更新:正如在下面的评论中提到的,这个包有一个更新的版本:
Java for OS X 2014-001(Correcting dead line above)
Java for OS X 2014-001(更正上面的死线)
Java for OS X 2014-001 includes installation improvements, and supersedes all previous versions of Java for OS X. This package installs the same version of Java 6 included in Java for OS X 2013-005.
适用于 OS X 2014-001 的 Java 包括安装改进,并取代适用于 OS X 的所有先前版本的 Java。此软件包安装与适用于 OS X 2013-005 的 Java 中包含的相同版本的 Java 6。
回答by dmz
回答by user260628
I downloaded manually to here: Java for OS X 2014-001.
我手动下载到这里:Java for OS X 2014-001。
After that open your terminal and check the installation with java -version
.
之后打开您的终端并使用java -version
.
EDIT (January, 2015): Also see HT202912, About Java for OS X 2014-001:
编辑(2015 年 1 月):另请参阅HT202912,关于 OS X 2014-001 的 Java:
回答by Rondo
The OP implied that Java 7 was the need. And Java 6 is in fact no longer being 'supported' so 7 is the version you should be installing at this point unless you have legacy app concerns.
OP 暗示需要 Java 7。并且 Java 6 实际上不再受“支持”,因此 7 是您此时应该安装的版本,除非您有遗留应用程序的问题。
You can get it here: http://java.com/en/download/mac_download.jsp?locale=en
你可以在这里得到它:http: //java.com/en/download/mac_download.jsp?locale=en
回答by analogue
If you only want to install the latest official JRE from Oracle, you can get it there, install it, and export the new JAVA_HOME in the terminal.
如果您只想从 Oracle 安装最新的官方 JRE,您可以在那里获取并安装它,然后在终端中导出新的 JAVA_HOME。
- Open your Terminal
java -version
gives you an error and a popup- Get the JRE dmg on http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Install it
- In your terminal, type:
export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
java -version
now gives youjava version "1.7.0_45"
- 打开你的终端
java -version
给你一个错误和一个弹出窗口- 在http://www.oracle.com/technetwork/java/javase/downloads/index.html上获取 JRE dmg
- 安装它
- 在您的终端中,键入:
export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
java -version
现在给你java version "1.7.0_45"
That's the cleanest way I found to install the latest JRE.
这是我发现安装最新 JRE 的最干净的方法。
You can add the export JAVA_HOME
line in your .bashrc
to have java
permanently in your Terminal:
您可以添加export JAVA_HOME
在您的生产线.bashrc
有java
在终端永久:
echo export JAVA_HOME=\"/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home\" >> ~/.bashrc
回答by Mr. Ronald
I downloaded and installed the JDK 1.7 from Oracle. In the console / in TerminalJava 7 works fine.
我从Oracle下载并安装了 JDK 1.7 。在控制台中/在终端Java 7 中工作正常。
When I start a Java program (like Eclipse) via the GUI, I get:
当我通过 GUI启动 Java 程序(如Eclipse)时,我得到:
To open "Eclipse.app" you need a Java SE 6 runtime. Would you like to install one now?
要打开“Eclipse.app”,您需要一个 Java SE 6 运行时。你想现在安装一个吗?
Because I did not want to install old Java version, I used the following workaround:
因为我不想安装旧的 Java 版本,所以我使用了以下解决方法:
sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
Credits to monkehWorks.
学分MonkehWorks。
回答by Marco Massenzio
The right place to download the JDK for Java 7 is Java SE Downloads.
下载 Java 7 JDK 的正确位置是Java SE 下载。
All the other links provided above, as far as I can tell, either provide the JRE or Java 6 downloads (incidentally, if you want to run Eclipseor other IDEs, like IntelliJ IDEA, you will need the JDK, notthe JRE).
所有其他链接上面提供的,据我所知,无论是提供JRE或Java 6次的下载(顺便说一句,如果你想运行的Eclipse或其他IDE,如IntelliJ IDEA的,你需要的JDK,不是在JRE)。
Regarding IntelliJ IDEA - that will still ask you to install Java 6 as it apparently needs an older class loader or something: just follow the instructions when the dialog pop-up appears and it will install the JDK 6 in the right place.
关于 IntelliJ IDEA - 它仍然会要求您安装 Java 6,因为它显然需要一个较旧的类加载器或其他东西:只需在弹出对话框时按照说明进行操作,它就会在正确的位置安装 JDK 6。
Afterwards, you will need to do the sudo ln -snf
mentioned in the answer above:
之后,您需要执行sudo ln -snf
上面答案中提到的操作:
sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents \
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
(copied here as it was mentioned that "above" may eventually not make sense as answers are re-sorted).
(复制到这里,因为提到“上面”可能最终没有意义,因为答案被重新排序)。
I also set my JAVA_HOME
to point to where jdk_1.7.0_xx.jdk
was installed:
我还设置JAVA_HOME
了指向jdk_1.7.0_xx.jdk
安装位置:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home"
Then add that to your PATH
:
然后将其添加到您的PATH
:
export PATH=$JAVA_HOME/bin:$PATH
The alternative is to fuzz around with Apple's insane maze of hyperlinks, but honestly life is too short to bother.
另一种选择是在 Apple 疯狂的超链接迷宫中四处游荡,但老实说,生命太短暂了,无法打扰。
回答by Eric Leschinski
From the OP:
来自 OP:
I finally reinstalled it from Java for OS X 2013-005. It solved this issue.
我终于从 Java 为 OS X 2013-005 重新安装了它。它解决了这个问题。
回答by Fabio Fumarola
This error happens because the plist file of IntelliJ IDEA requires Java version 1.6*. To solve this problem, replace the 1.6* with 1.8*.
发生此错误是因为 IntelliJ IDEA 的 plist 文件需要 Java 版本 1.6*。要解决此问题,请将 1.6* 替换为 1.8*。
<key>JVMOptions</key>
<dict>
<key>ClassPath</key>
...
<key>JVMVersion</key>
<string>1.8*</string>
<key>MainClass</key>
<string>com.intellij.idea.Main</string>
<key>Properties</key>
<dict>
回答by Muhammad Reda
My experience for updating Java SDK on OS X 10.9 was much easier.
我在 OS X 10.9 上更新 Java SDK 的经历要容易得多。
I downloaded the latest Java SE Development Kit 8
, from SE downloadsand installed the .dmg file. And when typing java -version
in terminal the following was displayed:
我Java SE Development Kit 8
从SE 下载中下载了最新的 .dmg 文件。java -version
在终端输入时,显示以下内容:
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
java版本“1.8.0_11”
Java(TM) SE 运行时环境(构建 1.8.0_11-b12)
Java HotSpot(TM) 64 位服务器 VM(构建 25.11-b03,混合模式)