rJava not loading in R

末鹿安然 提交于 2020-01-03 03:12:27

问题


So I tried everything I found online but with no luck. I am trying to use qdab library that requires rJava.

So I install rJava, try to run library("rJava") and get

> library("rJava")
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry
Error: package or namespace load failed for ‘rJava’

Then I tried to add path manually, by Sys.setenv and that's what's happening:

> Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\Java\\jre1.8.0_31")
> 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 'D:/Moje Dokumenty/R/win-library/3.1/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  %1 nie jest prawidłową aplikacją systemu Win32.

Error: package or namespace load failed for ‘rJava’

I reinstalled java, tried few other solutions but that should do it and it didn't. What else can I do ?


回答1:


Ok I solved it by installing 64bit Java and clearing JAVA_HOME in R using:

if (Sys.getenv("JAVA_HOME")!="")
  Sys.setenv(JAVA_HOME="")
library(rJava)



回答2:


I had the same problem until I installed the 64-bit version of Java. You have to manually download the 64-bit version. The default installer is the 32-bit version.

Follow this link to the manual download page:

http://www.java.com/en/download/manual.jsp



来源:https://stackoverflow.com/questions/28350723/rjava-not-loading-in-r

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