[英]OS X Yosemite not finding Java 8 runtime
I installed Java 8 SDK (with update 25 for JRE) from the Oracle Java site using the instructions on this page我使用此页面上的说明从 Oracle Java 站点安装了 Java 8 SDK(带有更新 25 的 JRE)
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html
and put the following line in my ~/.bash_profile
并将以下行放在我的
~/.bash_profile
export JAVA_HOME="/usr/libexec/java_home -v 1.8"
but when I try to compile or run a Java program in Bash I get the following message但是当我尝试在 Bash 中编译或运行 Java 程序时,我收到以下消息
No Java runtime present, requesting install.
and this window还有这个窗口
I ran /usr/libexec/java_home
to check:我跑
/usr/libexec/java_home
来检查:
$ /usr/libexec/java_home
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
But the JRE is in但是 JRE 在
/System/Library/Frameworks/JavaVM.framework/Versions/Current
and the JRE location in System Preferences is pointing to并且系统偏好设置中的 JRE 位置指向
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin
I don't know what the problem is here, but usr/bin/javac
and /usr/bin/java
are not able to find the correct JVM location in /System/Library/Frameworks/JavaVM.framework/Versions/Current
.我不知道这里有什么问题,但是
usr/bin/javac
和/usr/bin/java
无法在/System/Library/Frameworks/JavaVM.framework/Versions/Current
找到正确的JVM位置。
我遇到了同样的问题,我认为你应该安装JDK而不是JRE
You need to add some backticks:您需要添加一些反引号:
export JAVA_HOME="`/usr/libexec/java_home -v 1.8`"
The /usr/libexec/java_home
command outputs the right value for JAVA_HOME
on its standard output, you need to use backticks to capture that value so you can store it in the variable. /usr/libexec/java_home
命令在其标准输出上输出JAVA_HOME
的正确值,您需要使用反引号来捕获该值,以便将其存储在变量中。
But the JRE is in /System/Library/Frameworks/JavaVM.framework/Versions/Current
但是 JRE 位于 /System/Library/Frameworks/JavaVM.framework/Versions/Current
No, it isn't.不,它不是。 The Oracle JRE installs itself under
/Library/Internet Plug-Ins
, the Oracle JDK installs under /Library/Java/JavaVirtualMachines
. Oracle JRE安装在
/Library/Internet Plug-Ins
,Oracle JDK安装在/Library/Java/JavaVirtualMachines
。 The binaries under /usr/bin
and /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands
are stubs that delegate to whichever JDK your JAVA_HOME
variable points to. /usr/bin
和/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands
下的二进制文件是将JAVA_HOME
变量指向的任何 JDK 委托给的存根。
Here's how I solved my problem on my mac这是我在 Mac 上解决问题的方法
Check from RStudio if Java_HOME has been setup properly by running Sys.getenv("JAVA_HOME")
in the console.通过在控制台中运行
Sys.getenv("JAVA_HOME")
从 RStudio 检查 Java_HOME 是否已正确设置。 If it returns blank, you need to set it up properly如果返回空白,则需要正确设置
Check whether you have Java SDK installed检查您是否安装了 Java SDK
/usr/libexec/java_home -v
command./usr/libexec/java_home -v
命令。 This will show you the library where you Java SDK is installed. If you don't have Java SDK installed yet, result from command above is blank, or the version is not up-to-date, download here and install the latest version.如果你还没有安装Java SDK,上面命令的结果是空白,或者版本不是最新的,请在这里下载并安装最新版本。
Copy the library shown in step 2. On my mac, it shows: /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
复制步骤 2 中显示的库。在我的 Mac 上,它显示:
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
Back on your RStudio console, set the JAVA_HOME Sys.setenv(JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home")
回到你的 RStudio 控制台,设置 JAVA_HOME
Sys.setenv(JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home")
After doing the steps above, h2o.init()
ran without hitch.完成上述步骤后,
h2o.init()
运行顺利。
Please carefully note @Ian Robert's point on JRE vs JDK distinction.请仔细注意@Ian Robert 关于JRE与JDK区别的观点。 We need JDK to make h2o run.
我们需要JDK来运行 h2o。
I've tried several solutions, downloading several sdk but Android Studio didn't recognize them as valid sdks.我尝试了几种解决方案,下载了几个 sdk,但 Android Studio 没有将它们识别为有效的 sdk。
Finally, the workaround that worked for me was:最后,对我有用的解决方法是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.