when I execute the following code on Mac, I got this
**> library(xlsx)**
Loading required package: rJava
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error: package ‘rJava’ could not be loaded
I saw some posts here that changes the directory of Java Home, but they are all in Windows system. I am wondering how can I fix this in a Mac environment?
Try this
brew cask install java
In general, and to avoid similar problems in the future, I suggest to follow my post to install R using homebrew http://pacha.hk/2017-07-12_r_and_python_via_homebrew.html
Doing that solves path problems and related stuff that can re-appear if later you want to use R database tools and related.