rJava loading error- “character vector expected”

2019-06-11 22:20发布

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.

标签: r jvm rjava
2条回答
Juvenile、少年°
2楼-- · 2019-06-11 22:43

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.

查看更多
干净又极端
3楼-- · 2019-06-11 22:57

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.

查看更多
登录 后发表回答