How can I make rJava use the newer version of java on osx?

前端 未结 4 2185
粉色の甜心
粉色の甜心 2020-12-01 18:16

I am following this tutorial on rJava: http://cran.r-project.org/web/packages/helloJavaWorld/vignettes/helloJavaWorld.pdf

I have made all the files as specified in t

4条回答
  •  悲&欢浪女
    2020-12-01 19:20

    There's a lot of conflicting info about rJava on SO. My concern with a lot of these answers was that once you start monkeying with the JAVA_HOME variables, you run the risk of borking your Java install completely -- the solution can be worse than the disease. Here's a quick rundown of 'do no harm' things you can do if you are having rJava problems.

    1) in the terminal, run R CMD javareconf. This is a script written by R Core that will "Detect current Java setup and update the corresponding configuration in R." Take a look at the internals here.

    2) re-install rJava from source. install.packages("rJava", type = "source").

    3) Open R from the command line. Load rJava. Open RStudio from the command line (directions). Load rJava. Do you get the same error? If not, great - you're getting warmer! You've isolated your problem to an issue with RStudio, not R itself.

    4) There's some sort of issue with RStudio and rJava that relates to - actually, you know what, I'm not even going to try to finish that sentence, because frankly it's above my pay grade. Dynamic libraries something something.

    There are a bunch of writeups (here, here, here, and here) on the web about this. My favorite title was "the rJava nightmare."

    Your mileage may vary, but this SO answer was all I needed to get RStudio to play nice -- one line of code on the terminal, and all it does is creates a symbolic link. No changes to permissions, no modification of environment variables - just a simple symlink.

    If that doesn't do it for you, I'd suggest reading the linked blog posts above before you start copy/pasting the multitude of this worked for me answers littered across SO.

提交回复
热议问题