After many infuriating tries getting rJava to work, I've decided to do an Q&A of how I finally got it to work.
How do I install rJava on my MacOS system? I use macOS Catalina 10.15.6.
I frequently get warning messages of the type:
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.5/Resources/library/rJava/libs/rJava.so': dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, >6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk->11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib Referenced from: >/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so Reason: image not found
I've previously tried installing different JDK (Java Development Kit) from Oracle. I get the warning that RStudio only wants to work together with JDK-11.0.1. To download this I would need to create an Oracle account.
I've managed to solve this issue through the following steps:
rm.packages("rJava")
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr /Library/Application\ Support/Oracle/Java
Solution to remove unwanted previous version: https://stackoverflow.com/a/50056979/11550980
sudo rm -fr /Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk
If installing manually, unpack the .tar.gz file and place the unpacked folder in: /Library/Java/JavaVirtualMachines/
java -version
install.packages("rJava")
R CMD javareconf
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.