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.