⏱reading time: 8 min

Update 27th of March 2018 at 17.28 UTC+3: After talk a little bit on the R mail lists [1][2], it’s seems that it’s a know issue and they are on the way to fix this. Till them we have to stick to Java 9.0.4 to work with R.

Update 4th of April 2018 at 17.55 UTC+3: The rJava author just fix this in an update that haven’t been fed to CRAN yet, bu you can install from source from his repo on rforge.net using the following command:

Java 10 was just released a week ago on 20 March 2018 and I just updated to it using Homebrew Cask. However, I haven’t been able to make it work with R. As you know, I have a complete install of R with Homebrew, which I’m very happy with since it’s it easier to manage –in my opinion– and it’s faster. I would say also that R and Java are infamous for their bad relations and it’s not the first time that me and a whole bunch of people are driven nuts for not be able to configure it appropriately, even more in macOS.

In the moment of writing this post I’m on R 3.4.4 on macOS 10.13.3 with Java 10 and 9.0.4 installed.

First, I have to tell that I’m puzzle by something that it’s really intrigued, R CMD javarenconf and sudo R CMD javarendonf doesn’t yield the same result:

I really don’t understand why… with root privileges it uses Java 9.0.4 and without it uses Java 10 and it’s not only my computer but all the rest of the Mac computers I have around, one of it with El Capitan instead of High Sierra. If you know why is like this please tell me.

This problem has the consequence that if I choose Java 10 –or configure R with Java without root privileges– R and Java doesn’t behave properly. In other words, I’m not able to build rJava properly.

If we look closer to the error we can see that the source of the problem are, most probably, the highlighted lines –10 and 11– which mainly say javah can’t be found. I checked in /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/bin/ and it’s true that there isn’t a javah there. However, if I go the the Java 10 release notes they mention:


 JEP 313 Remove the Native-Header Generation Tool (javah)
As previously announced, the native-header tool, javah, has been removed.Native headers can now be generated by using the Java compiler, javac, with the -h option.

In other words, javah isn’t missing, they removed it on purpose. They stated there a way to create headers with Java, using the Java compiler, javac, with the -h option.

I’ve tried to to parse the this when running R CMD javareconf as:

But I haven’t succeeded since it’s using the /usr/bin/javah as the header generator, resulting again as an error when building rJava. Perhaps I’m not doing it right or it’s something more I should do.

If you have any idea, you are more than welcomed. I’ve opened a question in stackoverflow and a issue in rJava.

One thought on “R and Java 10

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.