我已经解决这个问题太久了,欢迎任何帮助。我终于安装并加载了 rJava,作为其中的一部分,我安装了 64 位 JRE 和 JDK。R 版本 3.2.2,64 位,在 64 位 Windows 7 上运行。尝试安装 xlsxjars(用于 xlsx 包)会出现很长的错误:
> install.packages("xlsxjars")
Installing package into ‘C:/Users/usr/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
installing the source package ‘xlsxjars’
trying URL 'https://cran.rstudio.com/src/contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 MB)
downloaded 9.0 MB
* installing *source* package 'xlsxjars' ...
** package 'xlsxjars' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : package 'rJava' is not installed for 'arch = i386'
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/usr/Documents/R/win-library/3.2/xlsxjars'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\usr\Documents\R\win-library\3.2" C:\Users\usr\AppData\Local\Temp\RtmpEJnPPp/downloaded_packages/xlsxjars_0.6.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsxjars’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\usr\AppData\Local\Temp\RtmpEJnPPp\downloaded_packages’
我专注于 i386 vs 64 架构,但我不确定这是否是现在的核心问题。我尝试手动将 JAVA_HOME 设置为下面的地址,并设置为 = "",但无论哪种方式都会出现相同的错误。
> system("java -version")
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
> library(rJava)
> Sys.getenv("JAVA_HOME")
[1] "C:/Program Files/Java/jdk1.8.0_65/jre/"
我还安装了 32 位 JDK,以防万一可以解决问题但没有骰子。这可能更多是关于 Java 而不是 xlsxjars,因为我尝试安装 XLConnect 作为解决方法,但遇到了类似的错误:
> install.packages("XLConnect")
Installing package into ‘C:/Users/usr/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
also installing the dependency ‘XLConnectJars’
installing the source packages ‘XLConnectJars’, ‘XLConnect’
trying URL 'https://cran.rstudio.com/src/contrib/XLConnectJars_0.2-9.tar.gz'
Content type 'application/x-gzip' length 12946884 bytes (12.3 MB)
downloaded 12.3 MB
trying URL 'https://cran.rstudio.com/src/contrib/XLConnect_0.2-11.tar.gz'
Content type 'application/x-gzip' length 5151325 bytes (4.9 MB)
downloaded 4.9 MB
* installing *source* package 'XLConnectJars' ...
** package 'XLConnectJars' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: library.dynam("rJava", pkgname, libname)
error: DLL 'rJava' not found: maybe not installed for this architecture?
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/usr/Documents/R/win-library/3.2/XLConnectJars'