Make rJava or R to use a different (previous) Java version

﹥>﹥吖頭↗ 提交于 2019-12-13 02:59:17

问题


It seems that the last java version makes rJava not able to load or compile / install.

Is there any way I can have java8 and java9 installed and force rJava or R use the java8 version?


Edit: It's been suggested that perhaps this thread is the solution to my problem, but it isn't. Since I need to use a lower version, not the new one. Seems that it's possible to tell R where is the java_home, but I don't know how.


回答1:


Take a look here: R, Java, rJava and macOS adventures and here: R 3.4, rJava, macOS and even more mess ;)

R, Java and proper settings that make every piece of software happy can be a struggle ;)

You need to play with JAVA_HOME, R CMD javareconf, and sometimes even compilation of rJava from sources.

If you need a specific version of Java just for R, you can always play with something like this.

First, get the list of JVMs

/usr/libexec/java_home -V
Matching Java Virtual Machines (4):
    9, x86_64:  "Java SE 9" /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
    1.8.0_144, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
    1.8.0_111, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
    1.7.0_80, x86_64:   "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home

Then, pick one just before starting R

-- start_R_with_Java_8.sh --
#!/bin/bash
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_144)
export PATH=$JAVA_HOME/bin:${PATH}
R

This way, in system you will have Java 9, while for R, you will have 1.8.



来源:https://stackoverflow.com/questions/46465618/make-rjava-or-r-to-use-a-different-previous-java-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!