[英]Why R is unable to load a shared object?
I am trying to use XLConnect
library in R. If I execute 我试图在R中使用
XLConnect
库。如果我执行
library(XLConnect)
I get the following error message: 我收到以下错误消息:
JAVA_HOME cannot be determined from the Registry
To resolve this problem I set first the JAVA_HOME
variable: 要解决此问题,我首先
JAVA_HOME
变量:
Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jre1.8.0_65')
library(XLConnect)
It looks like it helps me to come further but then I get another problem: 看起来它有助于我走得更远,但后来又遇到了另一个问题:
unable to load shared object 'C:/Program Files/R/R-3.2.2/library/rJava/libs/x64/rJava.dll'
It wonder why R cannot load rJava.dll
. 它想知道为什么R无法加载
rJava.dll
。 At least this file is located in the folder where R searches for it: 至少此文件位于R搜索它的文件夹中:
C:\Program Files\R\R-3.2.2\library\rJava\libs\x64
ADDED 添加
Please note that the rJava.dll
file exists and it is located there, where R is searching for it. 请注意,
rJava.dll
文件存在,它位于那里,R正在搜索它。 I guess that the problem is in incompatibility between 32bit and 64bit versions. 我想问题是32位和64位版本之间不兼容。 I assume that because R complains:
我认为因为R抱怨:
% 1 is not a valid Win32 application
Well, why do R expect it to be a Win32 application`? First, my OS is 64bit, second my Java is also for the 64bit and finally, the `rJava.dll` object is located in the folder with
好吧,为什么R期望它成为
Win32 application`? First, my OS is 64bit, second my Java is also for the 64bit and finally, the `rJava.dll` object is located in the folder with
Win32 application`? First, my OS is 64bit, second my Java is also for the 64bit and finally, the `rJava.dll` object is located in the folder with
x64` in the name (so, I assume it is also a 64bit version). Win32 application`? First, my OS is 64bit, second my Java is also for the 64bit and finally, the `rJava.dll` object is located in the folder with
名称中Win32 application`? First, my OS is 64bit, second my Java is also for the 64bit and finally, the `rJava.dll` object is located in the folder with
x64` Win32 application`? First, my OS is 64bit, second my Java is also for the 64bit and finally, the `rJava.dll` object is located in the folder with
中(因此,我认为它也是64位版本)。
I faced the same issue . 我遇到了同样的问题。 Please locate jvm.dll should be in (your JRE version could be different )
请找到jvm.dll应该在(您的JRE版本可能会有所不同)
C:\Program Files (x86)\Java\jre1.8.0_65\bin\client
or 要么
C:\Program Files (x86)\Java\jre1.8.0_65\bin\server
add this path to your windows system path and you are good to go .but keep in mind the version of jre and R should be consistent,if your java is in Program Files
its 64 bit so launch from 64 bit R
if its in Program Files (x86)
its 32 bit so use 32 bit R
将此路径添加到您的Windows系统路径并且您很高兴。但请记住jre和R的版本应该是一致的,如果您的Java在
Program Files
它的64位,那么如果它在Program Files (x86)
从64 bit R
启动Program Files (x86)
其32位所以使用32 bit R
You did use /
instead of \\
. 您确实使用
/
而不是\\
。
Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre1.8.0_65')
library(XLConnect)
I am using UNIX. 我正在使用UNIX。 Therefore I cannot test it by myself but your path might be wrong as well.
因此我不能自己测试它,但你的路径也可能是错的。
According to this post you can search it by using this: 根据这篇文章,您可以使用以下方法进行搜索:
find.java <- function() {
for (root in c("HLM", "HCU")) for (key in c("Software\\JavaSoft\\Java Runtime Environment",
"Software\\JavaSoft\\Java Development Kit")) {
hive <- try(utils::readRegistry(key, root, 2),
silent = TRUE)
if (!inherits(hive, "try-error"))
return(hive)
}
hive
}
credit goes to @nograpes for the function and this article for helping me giving you the answer. 感谢@nograpes的功能和本文帮助我给你答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.