rJava, R, Java and macOS is a mess.
What you can do is to try rebuild rJava from the sources.
Make sure to reconfigure Java. Due to the fact javareconf makes lots of strong assumptions when it comes to macOS and JAVA (one of these is, that whenever you have "Home" word, in JAVA_HOME variable, it will assume you want to use System wide Java - not quite good idea), you need to:
create "artificial" Home inside JDK, e.g.
cd /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents
ln -s Home RHome
export RHome as JAVA_HOME
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/RHome
Run javareconf with loots of switches that will make gcc with JNI based code compilation
`sudo R CMD javareconf JAVA_HOME=${JAVA_HOME} JAVA=${JAVA_HOME/bin/java JAVAC=${JAVA_HOME}/bin/javac JAVAH=${JAVA_HOME}/bin/javah JAR=${JAVA_HOME}/bin/jar JAVA_LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/server JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin"`
Download rJava package and try to rebuild it manually (outside R)
https://cran.r-project.org/web/packages/rJava/index.html
> curl https://cran.r-project.org/src/contrib/rJava_0.9-8.tar.gz -o rJava_0.9-8.tar.gz
> tar zxf rJava_0.9-8.tar.gz
> cd rJava
> ./configure
if it passes, start R (in the same console where you have set env)
> install.packages("rJava", type="source")
Note that with messy Java installations (Apple's JREs, Oracle's JDKs) you might need to play with setting up Java env propperly in a first place. It might be you will need some "dirty" hacks where you link javac, javah and jar from JDK inside JRE. You will know when you need to do it once ./configure
complains about missing commands.
It also might be needed to update file
`/usr/libexec/java_home`/../Info.plist
and make sure your JVM can handle JNI. You need to change:
<key>JVMCapabilities</key>
<array>
<string>CommandLine</string>
</array>
to
<key>JVMCapabilities</key>
<array>
<string>CommandLine</string>
<string>JNI</string>
</array>
After some struggle, you might get it working fine. However, it's really system dependent. A lot depends on what version of R you have, whether you have JDK installed or not and what is your default JVM.
Note!
rJava requires XQuartz for compilation, make sure to install it as well
https://www.xquartz.org
.C()
and.Fortran()
calls are resolved. That is in the NEWS file I pointed you to.