Why does rJava cause so many issues?

It seems like calling Java from R is ripe with pitfalls and issues. Given that Java and R are both cross platform I’m wondering why there are so many problems using Java from R? Does anyone have any insight into the reasons for the problems with using rJava issues? Why does Rstudio recommend odbc instead of JDBC for example?

Since your question probably doesn't have an objective answer, I'll chime in with my speculations.

Personally, I'm not even sure rJava specifically is the problem. To me it seems more like Java itself is always breaking in subtle ways that require a bit of CLI voodoo to bring it back to life. Once you can make Java work properly 9 times out of 10 the sudo R CMD javareconf makes sure that rJava works without issues.

And given that there are so many issues with Java, I'd say it's no wonder that odbc is recommended over JDBC. I'm one of those people who would always recommend to first try doing whatever you are doing with odbc and only if it doesn't work for some reason to try and make rJava work.


Thanks for your thoughts. Would you mind giving an example of Java breaking in a subtle way that is fixed with CLI voodoo? I’m just wondering about the best way to verify that Java is working properly, ideally from R.

I've updated to Ubuntu 20.04 and rJava broke.
I've updated to R 4.0.0 and out of all 400+ packages I have only rJava broke.

And all in all here and in other channels rJava seems to be the common culprit where installing the package is not straight-forward. You can probably argue that it's probably not Java's fault, but given that rJava is de-facto standard way of interacting with Java from R all blame goes to Java when something is not working correctly.

After my latest run-in with rJava, I've finally bookmarked this SO question where there are couple of solutions that worked for me - https://stackoverflow.com/questions/42562160/r-cmd-javareconf-not-finding-jni-h

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.