R, loading rJava error

前端 未结 2 725
时光取名叫无心
时光取名叫无心 2020-12-06 12:35

I\'m running R (version 3.4.0) on macOS sierra (10.12.5) and I\'m trying to use the xlsx library which requires the use of the rJava library.

When I try to load rJav

2条回答
  •  粉色の甜心
    2020-12-06 12:40

    JAVA_HOME path is different for different version of MAC OS. In some cases there is /jre folder and in some cases it is not after /Home director manually go towards /server folder with CD command in terminal and using pwd copy the entire path use that to set the java.home then you can easily load rJava library. This is how I was able to fix the issue

    options("java.home"="/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/lib")
    
    Sys.setenv(LD_LIBRARY_PATH='$JAVA_HOME/server')
    
    dyn.load('/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/lib/server/libjvm.dylib')
    
    library(rJava)
    

提交回复
热议问题