如何在 Mac 上安装 Java 8 [英] How to install Java 8 on Mac
问题描述
编者注:这个问题是在 2014 年提出的,答案可能已经过时.
Editors note: This question was asked in 2014, and the answers may be outdated.
我想使用需要 Java 8 的最新 JavaFX 进行一些编程.我使用的是 IntelliJ 13 CE 和 Mac OS X 9 Mavericks.我运行了 Oracle 的 Java 8 安装程序,文件看起来像是在
I want to do some programming with the latest JavaFX, which requires Java 8. I'm using IntelliJ 13 CE and Mac OS X 9 Mavericks. I ran Oracle's Java 8 installer, and the files look like they ended up at
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk
但以前的版本在
/System/Library/Java/JavaFrameworks/jdk1.6....
不知道为什么最新的安装程序把它放在 /Library
而不是 /System/Library
(也不知道有什么区别).但是 /usr/libexec/java_home
没有找到 1.8,所以我找到的关于如何设置当前 java 版本的所有帖子都不起作用.我尝试添加一个符号链接,使其看起来像 1.8 位于 /System/Library...
路径中,但它没有帮助./usr/libexec/java_home -V
仍然只列出旧的 Java 1.6.
Not sure why the latest installer puts this in /Library
instead of /System/Library
(nor what the difference is). But /usr/libexec/java_home
doesn't find 1.8, so all the posts I've found on how to set your current java version don't work. I've tried adding a symbolic link to make it look like 1.8 is in the /System/Library...
path, but it doesn't help. /usr/libexec/java_home -V
still only lists the old Java 1.6.
具有讽刺意味的是,Java"系统偏好设置下的控制面板仅显示 Java 1.8!
Ironically, the "Java" control panel under System Preferences shows only Java 1.8!
为什么 Oracle 的安装程序不把它放在真正需要的地方?我该如何解决这个问题?
Why doesn't Oracle's installer put it where it really goes? And how can I work around this problem?
推荐答案
Oracle 在简化 Java 安装和配置方面的记录不佳,但使用 Homebrew,最新的 OpenJDK (Java 14) 可以安装:
Oracle has a poor record for making it easy to install and configure Java, but using Homebrew, the latest OpenJDK (Java 14) can be installed with:
brew install --cask adoptopenjdk8
对于依赖于旧版本(通常是 Java 8)的许多用例,AdoptOpenJDK 项目使其成为可能一个额外的步骤.
For the many use cases depending on an older version (commonly Java 8), the AdoptOpenJDK project makes it possible with an extra step.
brew tap adoptopenjdk/openjdk
brew install --cask adoptopenjdk8
Homebrew 的现有用户可能会遇到 Error: Cask Adoptopenjdk8 exists in multiple taps
由于之前使用不同指令的变通方法.这可以通过使用 brew install --cask Adoptopenjdk/openjdk/adoptopenjdk8
完全指定位置来解决.
Existing users of Homebrew may encounter Error: Cask adoptopenjdk8 exists in multiple taps
due to prior workarounds with different instructions. This can be solved by fully specifying the location with brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
.
这篇关于如何在 Mac 上安装 Java 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!