rJava 安装错误“无法从注册表中确定 JAVA_HOME”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29522088/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:09:52  来源:igfitidea点击:

rJava install error "JAVA_HOME cannot be determined from the Registry"

javarerror-handlingrjava

提问by Eric

I am trying to load the rJava using the command:

我正在尝试使用以下命令加载 rJava:

 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!

我尝试使用最新版本重新安装 Java 和 R 程序,但仍然出现这些错误..我可以知道如何解决这个问题吗?非常感谢!

采纳答案by Raja Anbazhagan

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.

通常通过安装适合您使用的 R 版本类型(即 64 位 R 或 32 位 R)的 Java 版本(即 64 位 Java 或 32 位 Java)来解决此错误。此问题很容易影响 Windows 7 用户,因为他们安装的 Java 版本可能与他们使用的 R 版本不同。

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

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

回答by TomaszGuzialek

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.

R for Windows 安装程序默认安装 32 位和 64 位文件。重新安装 R 并取消勾选 32 位部分为我解决了这个问题。

回答by Shawn Cefalu

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.

如上面引用的 r-statistics 链接所述,您必须手动下载 64 位版本的 Java。如果没有,则将安装 32 位版本。

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.

因此,如果您有 64 位操作系统,请确保 R 和 Java 都使用 64 位安装。否则,这个问题会一直存在。

回答by AnksG

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. ,

通过安装相同版本的 R 和 Java(即 64 位)并手动更新路径,即解决了相同的错误,

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

回答by Xiao QianYu

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)
  1. 为 64 位安装 Java
  2. 在windows命令中运行以下代码
    setx PATH "C:\Program Files\Java\jre1.8.0_171\bin\server;%PATH%"
    (请将地址更改为您的dvm.dll真实地址)
  3. 在R studio下面运行 Sys.setenv(JAVA_HOME="")
    然后我终于可以运行了
    library(rJava)
    library(xlsx)

回答by Balasaheb Sonawane

Install 64 bit Java from https://java.com/en/download/manual.jsp.
Then in windows cmd run
setx PATH "C:\Program Files\Java\jre1.8.0_211\bin\server;%PATH%"
(make sure your path is correct).

https://java.com/en/download/manual.jsp安装 64 位 Java 。
然后在 Windows cmd 中运行
setx PATH "C:\Program Files\Java\jre1.8.0_211\bin\server;%PATH%"
(确保您的路径正确)。

Then in RStudio run
Sys.setenv(JAVA_HOME="")

然后在 RStudio 中运行
Sys.setenv(JAVA_HOME="")

Now, you should be able to run rJava!!

现在,您应该可以运行 rJava 了!!

回答by Mina Saleh

If R is 64-bit version make sure to install Java 64-bit version!

如果 R 是 64 位版本,请确保安装 Java 64 位版本!

If R is x86-bit version make sure to install Java x86-bit version!

如果 R 是 x86 位版本,请确保安装 Java x86 位版本!

回答by Vela

I faced the same issue and was feeling very down as I couldnt get my analysis done. This worked for me :

我遇到了同样的问题,并且因为无法完成分析而感到非常沮丧。这对我有用:

  1. check your operating system. 64 bit or 32 bit. https://helpx.adobe.com/x-productkb/global/determine-whether-computer-running-32.html

  2. uninstall previous versions of Java.

  3. delete rJAVA library from Doc>R>win-library. If you have more than 1 versions of R, make sure you delete rJAVA package from all of them.

  4. install Java based on system requirement (64 bit or 32 bit).

  5. and finally restart R before and after installing rJava package.

  1. 检查您的操作系统。64 位或 32 位。 https://helpx.adobe.com/x-productkb/global/determine-whether-computer-running-32.html

  2. 卸载以前版本的 Java。

  3. 从 Doc>R>win-library 中删除 rJAVA 库。如果您有 1 个以上的 R 版本,请确保从所有版本中删除 rJAVA 包。

  4. 根据系统要求(64 位或 32 位)安装 Java。

  5. 最后在安装 rJava 包之前和之后重新启动 R。