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.

2
  • 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. Commented Jan 5, 2018 at 16:27
  • @abhiieor Yes, I get the version when I run the command Commented Jan 13, 2018 at 6:22

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This did not solve the problem either. I am still getting the same error
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.