由于 rJava 尝试在 R 中加载包时出现的问题

由于 rJava 尝试在 R 中加载包时出现的问题

问题描述:

当我键入 require(xlsx) 以在 R 中加载包 xlsx 时,显示以下消息:

When I type require(xlsx) in order to load the package xlsx in R, the following messages is shown:

> require(xlsx)
Loading required package: xlsx
Loading required package: xlsxjars
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
Failed with error:  ‘package ‘rJava’ could not be loaded’

我也尝试手动加载 rJava 包,但收到此错误消息:

I've also tried to load the rJava package manually but got this error message:

require(rJava)
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.

您对如何解决问题有什么建议吗?

Do you have any suggestion on how to solve the problem?

原因可能与您使用的是 64 位 OS 和 R 版本但没有安装 Java 相关相同的架构.您需要做的是从此页面下载 Java 64 位:https://www.java.com/en/download/manual.jsp

The reason is probably linked to the fact you are using a 64-bit OS and R version but do not have Java installed with the same architecture. What you have to do is to download Java 64-bit from this page: https://www.java.com/en/download/manual.jsp

然后尝试重新加载 xlsx 包.您不应该需要重新启动 R.

After that just try to reload the xlsx package. You shouldn't need to re-start R.