简体   繁体   English

R / RStudio,Yosemite和Java

[英]R/RStudio, Yosemite, and Java

I upgraded to OSX Yosemite yesterday. 我昨天升级到了OSX Yosemite。 When I run library(xlsx) in RStudio , the program crashes and I get the message: "To open 'RStudio' you need to install the legacy Java SE 6 runtime." 当我在RStudio运行library(xlsx)时,程序崩溃,我收到消息:“要打开'RStudio',您需要安装旧的Java SE 6运行时。” I get the same result and message about opening R when I run library(xlsx) in R . 当我在R运行library(xlsx)时,我得到了关于打开R的相同结果和消息。

Here are my details: 这是我的详细信息:

Mac Yosemite, Version 10.10.2
R version 3.1.2 (2014-10-31) 
Platform: x86_64-apple-darwin13.4.0 (64-bit)

I have Java Version 8 update 31. I ran java -version and got this message: "No Java runtime present, requesting install." 我有Java版本8更新31.我运行java -version并收到此消息:“没有Java运行时,请求安装。” So I installed Java SE Development Kit 8u31 . 所以我安装了Java SE Development Kit 8u31 Now: 现在:

java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

This did not do the trick because running library(xlsx) still crashes the program and throws a warning. 这没有做到这一点,因为运行library(xlsx)仍然崩溃程序并抛出警告。 Do I need to somehow roll back to Java SE 6 runtime, or is there a way to use the latest version I have installed? 我是否需要以某种方式回滚到Java SE 6运行时,还是有办法使用我安装的最新版本?

This SO post seems to be related, but I am not clear about the propsoed solution to install Java 6. The answer links to an apple support page that seems out of date. 这个SO帖子似乎是相关的,但我不清楚安装Java 6的安装解决方案。答案链接到似乎过时的苹果支持页面

I'm not familiar with Java, so I could use some advice. 我不熟悉Java,所以我可以使用一些建议。

instead the java you have installed download this one 相反,你安装的java下载这个

https://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US https://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US

after installing it, your problem will be solved 安装后,您的问题将得到解决

This worked for me: setting two env variables in ~/.profile 这对我有用:在〜/ .profile中设置两个env变量

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/server

I can install the rJava and xlsx packages in Rstudio as such. 我可以在Rstudio中安装rJava和xlsx包。 Admittedly, though, it took hours of tinkering around (mindlessly) to get it just right. 不可否认,它需要数小时的修补(无意识地)才能使它恰到好处。

I was able to get rJava loaded with Java 8. It looks like this is a problem with RStudio not passing certain environment variables into its rsession from Yosemite. 我能够让rJava加载Java 8.看起来这是一个问题,RStudio没有将某些环境变量传递给Yosemite的rsession。 Hopefully they'll fix it soon, but in the mean time you can pass the environment variable yourself in a terminal. 希望他们能尽快修复它,但同时您可以在终端中自行传递环境变量。 Run this: 运行这个:

$LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio $ LD_LIBRARY_PATH = $(/ usr / libexec / java_home)/ jre / lib / server:open -a RStudio

Basically what you're doing here is running the java_home executable, which returns your Java path, and then appending the jre/lib/server directory. 基本上你在这里做的是运行java_home可执行文件,它返回你的Java路径,然后附加jre / lib / server目录。 This gets assigned to LD_LIBRARY_PATH, which is what RStudio needs to correctly. 这被分配给LD_LIBRARY_PATH,这是RStudio正确需要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM