rJava and library(xlsx)

I am trying to use the package xlsx on Mac running Sierra, but get an error as follows:

Error: package ‘rJava’ could not be loaded

Please assist

Is rJava installed? Try running install.packages("rJava")

Many thanks. Yes i did run this. I found the following solution on Stackoverflow:

Run:

sudo ln -f -s $(/usr/libexec/java_home)/lib/server/libjvm.dylib /usr/local/lib

and

ln -s /usr/local/lib/libjvm.dylib /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/

This worked for me

2 Likes

Hi,

I have a similar if not the same issue. I've solved it by running
dyn.load(paste0(system2('/usr/libexec/java_home', stdout = TRUE), '/jre/lib/server/libjvm.dylib'))
in every R-script before loading xlsx and rJava with it. Also found this on Stackoverflow.
Now I have to run this every time I load rJava. This is not convenient. Will your solution, chitemerere, also work on my system (latest High Sierra)?

Thanks.