3
votes

I want to install rJava

install.packages("rJava")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/rJava_0.9-8.zip'
Content type 'application/zip' length 713967 bytes (697 KB)
downloaded 697 KB

package ‘rJava’ successfully unpacked and MD5 sums checked

I have tried

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_121')
library(rJava)

But I receive

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:/Users/.../Documents/R/R-3.3.2/library/rJava/libs/x64/rJava.dll': LoadLibrary failure: %1 is not a valid Win32 application. nd. package or namespace load failed for ‘rJava’

I have tried even with the x86 version but I do not know how to fix this!

platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.2
year 2016
month 10
day 31
svn rev 71607
language R
version.string R version 3.3.2 (2016-10-31) nickname Sincere Pumpkin Patch

1
Are you running 32-bit or 64-bit Windows? You need to use the appropriate 32/64 bit JRE. Did you really get the same exact error message when trying both? - Tim Biegeleisen

1 Answers

0
votes

I had the same problem. The below worked with me.

options(java.home="C:\\Program Files\\Java\\jdk1.8.0_65\\jre")
install.packages("rJava")
install.packages("XLConnect")
install.packages("XLConnectJars")
library(rJava)
library(XLConnect)
library(XLConnectJars)

I know this is not the occam's razor because my script above probably has some unnecessary lines. But at least I solved the same problem with this.