如何在 64 位 Windows 计算机上安装 rJava 以与 64 位 R 一起使用?
我安装了 iplots 和 rjava 软件包。当我做这个库(iplots)时,我收到以下错误。我的电脑上确实安装了 JDK。
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
错误:无法加载包“rJava”
I installed iplots and rjava packages. When I do this library(iplots), I get the following error. I do have JDK installed on my pc.
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package ‘rJava’ could not be loaded
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
该错误告诉您注册表中没有任何条目可以告诉 R Java 在您的计算机上的位置。要么您的注册表已损坏,但更可能的是您尚未安装 Java。您可以安装 Java 运行时环境或 Java 开发工具包。
(您可以在此处下载 Java。)
如果您安装了 Java,请尝试重新安装它。这应该会将条目放回到您的注册表中。
如果这不起作用,您可以开始查看 R 在哪里查找您的注册表项。 rJava用来查找Java的函数在rJava:::.onLoad函数中。该函数中有一个名为 find.java 的子函数。我将内容复制到此处:
将其复制并粘贴到 R 窗口中,然后运行
find.java()
。 rJava 正在寻找 JavaHome 的条目。如果未列出,则说明您的注册表中缺少该文件。您还可以在加载库之前手动设置 Java 位置的目录:
The error is telling you that there is no entry in your Registry that tells R where Java is located on your machine. Either your registry is corrupt, but more likely you haven't installed Java. You can install either the Java Runtime Environment or the Java Development Kit.
(You can download Java here.)
If you installed Java, try reinstalling it. This should put the entries back in your Registry.
If that doesn't work, you can start looking at exactly where R is looking for your Registry entries. The function that rJava uses to find Java is in the rJava:::.onLoad function. Within that function there is a subfunction called find.java. I copy the contents here:
Copy and paste this into your R window, and then run it
find.java()
. rJava is looking for an entry for JavaHome. If that isn't listed, then it is missing from your registry.You could also manually set the directory of your Java location by setting it before loading the library:
如果像我一样,您没有安装 64 位 Java 的管理员权限,只需打开 32 位 R,它应该可以在您的 64 位 PC 上正常工作,因为问题的一部分似乎是 rJava 库函数调用嵌入式 Java 函数/例程,它可能只针对 Excel/Windows 的 32 位接口而设计,并且当时的任务可能太大而无法更改所有内容。
If like me you do not have admin rights to install 64-bit Java, just open 32-bit R and it should work ok on your 64 bit PC as part of the problem seems to be the rJava library function calls embedded Java functions/routines, which may only have being designed for 32-bit interface with Excel/Windows and possibly too large a task at the time to change everything.
链接中的答案解决了我的问题。
在解决之前,我尝试将JAVA_HOME添加到Windows环境中。它解决了这个错误,但又产生了另一个问题。上述链接中的解决方案解决了此问题,而不会产生其他问题。
Answer in link resolved my issue.
Before resolution, I tried by adding JAVA_HOME to windows environments. It resolved this error but created another issue. The solution in above link resolves this issue without creating additional issues.
任何 Linux 用户,请运行命令:
sudo R CMD javareconf
通常需要在系统 Java 安装更新后运行,
按照此处的建议
Any Linux users here, run command:
sudo R CMD javareconf
That typically needs to be run after an update of the system Java installation,
as suggested here