2

I am using 64 bit windows 7 & 64 bit R 3.2.0. I have downloaded rJava package, but it is giving an error as follows.

Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dirname(this$RuntimeLib) error: a character vector argument expected In addition: Warning message: package ‘rJava’ was built under R version 3.2.2 Error: package or namespace load failed for ‘rJava’

I searched stackoverflow for answers, and did the following:

1) Added the jvm.dll file to my PATH variable, i.e. in the following directory:

C:\Program Files\Java\jdk1.8.0_25\jre\bin\

2) I am using 64 bit R 3.2.0 & checked if the JVM version was 64 bit or not, typing the following on the command line:

java -d64 -version

It gave the following output:

C:\Users\xyz> java -d64 -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

So at least the JVM matches with R.

So what more needs to be done to make rJava work? I also checked my PATH variable and it seems okay.

Cyrus Mohammadian
  • 4,982
  • 6
  • 33
  • 62
nb1
  • 125
  • 1
  • 3
  • 11
  • Take a look [here](http://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r) and [here](http://stackoverflow.com/questions/3311940/r-rjava-package-install-failing) perhaps – David Arenburg Oct 19 '15 at 10:14
  • Thank you. This thread had the answer. http://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r I tried this thing therein: But what's probably the best solution (since rJava 0.9-4) is overriding within R the Windows JAVA_HOME setting altogether: {options(java.home="C:\\Program Files\\Java\\jre7\\") library(rJava)} – nb1 Oct 19 '15 at 10:25
  • I followed instructions as given in one of your links but it is still giving the error "jvm.dll" is not present in the machine even when I have it in my Java path. – nb1 Oct 19 '15 at 10:43
  • Oh, I thought your problem was solved, reopening... Did you try both links btw? – David Arenburg Oct 19 '15 at 10:44
  • I thought the same when I did not get any error for some time, but then my PC hanged and after closing and restarting R, it is giving this error "jvm.dll not found in your machine". As to the both links- I tried only one since the second one is about doing things in linux and I am using windows. I also created a JAVA_HOME environment variable and added the Java path therein. – nb1 Oct 19 '15 at 10:50
  • jvm.dll is in `C:\Program Files\Java\jdk1.8.0_25\jre\bin\server` – user3083324 Nov 15 '16 at 23:31

2 Answers2

6

I know this is way too late, but did you try switching R versions as a diagnostic step?

For RStudio 1.0.136: Tools -> Global Options... -> General: R version: Change - Choose 32 bit.

Changing versions worked for me and prompted me to revisit my java installation. (Ended up just using R32)

Got the same error with R64:

Loading required package: XLConnectJars
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: dirname(this$RuntimeLib)
  error: a character vector argument expected
Error: package ‘XLConnectJars’ could not be loaded

Was running RStudio on Windows 10 using machine's default R64.

AChervony
  • 663
  • 1
  • 10
  • 15
5

Ya must specify where the jdk is. For example:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk1.8.0_161')

then it should work.

stakowerflol
  • 979
  • 1
  • 11
  • 20