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

2
  • 2
    This did not solve the problem either. I am still getting the same error
    – Regime
    Commented Jan 13, 2018 at 6: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
    Commented Jan 13, 2018 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.