1

I have been trying to load rJava onto my RStudio setup and it just won't work. It installs fine but doesn't load when I use the command library(rJava).

Here's what I've tried:-

  1. I have installed the latest version of jdk which is jdk 9.0.1.
  2. I have tried changing the JAVA_HOME environment variable to the jdk location.
  3. I have tried everything in this question as well but it didn't work.

I have attached the screenshot of the error message:

enter image description here

I am working on a MacBook.

user20650
  • 24,654
  • 5
  • 56
  • 91
Regime
  • 23
  • 4
  • I hope JRE is there i.e. `java -version` prints the version. Plus I remember in mac rJava installation is tricky due to gcc version as well. – abhiieor Jan 05 '18 at 16:27
  • @abhiieor Yes, I get the version when I run the command – Regime Jan 13 '18 at 06:22

1 Answers1

1

There is a very specific sequence of steps that must be taken to get rJava to work on a Macbook, as documented in rJava Issues #86.

  1. Download and install Java from Oracle
  2. Uninstall any previously installed version of rJava
  3. Add JAVA_HOME to your .bashrc
  4. Close & restart terminal, R and RStudio sessions so they pick up the updated JAVA_HOME
  5. Use install.packages() to install rJava

See the URL link above for additional details on each step.

Len Greski
  • 10,505
  • 2
  • 22
  • 33
  • 2
    This did not solve the problem either. I am still getting the same error – Regime Jan 13 '18 at 06:21
  • 1
    Also, I get a new error when I run the command sudo R CMD javareconf -n. It shows that it could not find jni.h. – Regime Jan 13 '18 at 06:33