rJava install error “JAVA_HOME cannot be determined from the Registry”

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I am trying to load the rJava using the command:

 library(rJava) 

But I get the following error:

 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’ 

I tried reinstalling both the Java and the R program with the latest versions but still get these errors.. May I know how I can resolve this? Thank you very much!

回答1:

This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.

http://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/



回答2:

R for Windows installer installs by default both 32-bit and 64-bit files. Reinstalling R and unticking 32-bit part solved the problem for me.



回答3:

As mentioned in the r-statistics link cited above, you have to manually download the 64-bit version of Java. If not, then the 32-bit version will be installed.

So, if you have a 64-bit operating system, then ensure that both R and Java are using the 64-bit installs. Otherwise, this problem will persist.



回答4:

This has been killing me and I have tried multiple methods above, it doesn't work. After, I mix all solution to try and below process works for me.

  1. Install Java for 64 bit
  2. Run below code in windows command setx PATH "C:\Program Files\Java\jre1.8.0_171\bin\server;%PATH%" (please change the address acorrding to your dvm.dll real address)
  3. run below in R studio Sys.setenv(JAVA_HOME="") Then I finally can run library(rJava) library(xlsx)


回答5:

I got the same error resolved by installing same version of R and Java i.e. 64 bits and manually updating the path i.e. ,

Sys.setenv(JAVA_HOME='C:/Program Files/Java/jre1.8.0_121') # for 64-bit version 


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