Search code examples
javarrjava

rJava not loading in R


So I tried everything I found online but with no luck. I am trying to use qdab library that requires rJava.

So I install rJava, try to run library("rJava") and get

> library("rJava")
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry
Error: package or namespace load failed for ‘rJava’

Then I tried to add path manually, by Sys.setenv and that's what's happening:

> Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\Java\\jre1.8.0_31")
> library("rJava")

Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'D:/Moje Dokumenty/R/win-library/3.1/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  %1 nie jest prawidłową aplikacją systemu Win32.

Error: package or namespace load failed for ‘rJava’

I reinstalled java, tried few other solutions but that should do it and it didn't. What else can I do ?


Solution

  • Ok I solved it by installing 64bit Java and clearing JAVA_HOME in R using:

    if (Sys.getenv("JAVA_HOME")!="")
      Sys.setenv(JAVA_HOME="")
    library(rJava)