14

I upgraded to OSX Yosemite yesterday. 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." I get the same result and message about opening R when I run library(xlsx) in 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." So I installed 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. 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?

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.

I'm not familiar with Java, so I could use some advice.

Community
  • 1
  • 1
Eric Green
  • 7,385
  • 11
  • 56
  • 102
  • you can also (from Terminal.app) `open -a RStudio` (provided your env vars are all setup well) and it will (shld) also work fine with newer JVMs. – hrbrmstr Mar 02 '15 at 00:05

3 Answers3

13

instead the java you have installed download this one

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

after installing it, your problem will be solved

  • @Eric Green welcome! Eric, if I were you, I would not upgrade to Yosemite, OMG, so many issues coming with it. Welcome to challenge :-D –  Mar 01 '15 at 17:35
  • 1
    I thought I waited long enough for the issues to be sorted out. Sad! – Eric Green Mar 01 '15 at 20:00
  • @Eric Green I personally downgraded to mavericks! if once you decided to do so, don't hesitate to comment, I will explain you how to do it :-) –  Mar 01 '15 at 21:25
  • @Nemo I'm facing the same issue. Does this mean the problem is coming from OS X? I would have though more from R or RStudio... I don't really want to install such an old Java version – LudoMC May 05 '15 at 22:13
  • @LudoMC This is evidently a Java 1.8 bug. See https://github.com/s-u/rJava/issues/37 and https://bugs.openjdk.java.net/browse/JDK-7131356. – leekaiinthesky Jun 17 '15 at 16:00
  • yeah, and this screws up all the other applications that actually *need* Java 8, such as Bamboo... So, by "solving" one problem, you created a host of other ones. With Java, most problems cannot be kept in a neat sandbox. And a personal vendetta against a certain version of an operating system should be kept out of the comments. @leekaiinthesky's comment is much more helpful. – yogibimbi Oct 13 '15 at 15:08
2

This worked for me: setting two env variables in ~/.profile

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. Admittedly, though, it took hours of tinkering around (mindlessly) to get it just right.

awfulHack
  • 857
  • 1
  • 10
  • 25
2

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. 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

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. This gets assigned to LD_LIBRARY_PATH, which is what RStudio needs to correctly.

Dr. Arun
  • 176
  • 6