rJava loading error- “character vector expected”

冷暖自知 提交于 2019-12-08 05:33:35

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/33211810/rjava-loading-error-character-vector-expected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!