Unable to load rJava on R Unable to load rJava on R r r

Unable to load rJava on R


Use:

Sys.setenv(JAVA_HOME='...path to JRE...')

e.g.

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk1.7.0_51\\jre')

Your environment variable is wrong.


I got a similar error:

> 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 'C:/program files/R/R-3.1.2/library/rJava/libs/x64/rJava.dll':  LoadLibrary failure:  The specified module could not be found.

My JAVA_HOME was pointing to JDK, rather than JRE.

> Sys.getenv("JAVA_HOME")[1] "c:\\java\\jdk1.7.0_55"> Sys.setenv(JAVA_HOME="c:\\java\\jdk1.7.0_55\\jre")

I could now load rJava and xlsx in R.


I've met a similar problem and spent an entire day to get it fixed. Although my computer, windows7, and Rstudio are 64 bit, but my Java is 32 bit(!) Once I realized that, I download a 64 bit Java. I have to manually download, the automatic download will lead to the 32 bit version because my chrome browser is 32 bit. 64 bit Java will be automatically installed in

C:\Program Files\Java, however, 32 bit Java will be automatically installed in C:\Program Files (x86) \Java.

This is an important indicator telling me my Java is 64 bit or 32 bit.

After installing the 64 bit Java, everything works perfect!