javar32bit-64bitxlsxxlconnect

R - Cannot install xlsxjars, 64-bit Windows but trying to load i386


I have been at this problem for far too long now, any help welcomed. I finally got rJava installed and loaded, and as part of it I installed the 64-bit JRE and JDK. R version 3.2.2, 64-bit, running on 64-bit Windows 7.Trying to install xlsxjars (for xlsx package) gives a long error:

> 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’

I'm fixated on the i386 vs 64 architecture, but I'm not sure if that's the core problem right now. I've tried manually setting the JAVA_HOME to the address below, and also setting as = "", but the same error arises either way.

> 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/"

I also installed the 32-bit JDK in case that would solve the issue but no dice. This could be more about Java than xlsxjars, as I tried to install XLConnect as a workaround but came to a similar error:

> 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'

Solution

  • Solved,

    install.packages("xlsx", INSTALL_opts="--no-multiarch")
    

    Found on this question by Adi and the sub-comment by Dason.