[R] library(xlsx) fails with an error: Error: package ‘rJava’ could not be loaded

Rainer Hurling rhurlin at gwdg.de
Sun Apr 19 12:02:44 CEST 2015


Hi John,

Am 18.04.2015 um 22:07 schrieb John Sorkin:
> Windows 7 64-bit
> R 3.1.3
> RStudio 0.98.1103
> 
> 
> I am having difficulty loading and installing the xlsx package. The
> loading occurred without any problem, however the library command
> library(xlsx) produced an error related to rJava. I tried to install
> rJava seperately, re-loaded the xlsx package, and entered the
> library(xlsx) command but received the same error message about rJave.
> Please see terminal messages below. Any suggestion that would allow me
> to load and run xlsx would be appreciated.
> Thank you,
> John
> 
> 
>> install.packages("xlsx")
> Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
> (as ‘lib’ is unspecified)
> trying URL
> 'http://cran.rstudio.com/bin/windows/contrib/3.1/xlsx_0.5.7.zip'
> Content type 'application/zip' length 400944 bytes (391 KB)
> opened URL
> downloaded 391 KB
> 
> 
> package ‘xlsx’ successfully unpacked and MD5 sums checked
> 
> 
> The downloaded binary packages are in
> 	C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
>> library(xlsx)
> Loading required package: rJava
> Error : .onLoad failed in loadNamespace() for 'rJava', details:
>   call: inDL(x, as.logical(local), as.logical(now), ...)
>   error: unable to load shared object
> 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
>   LoadLibrary failure:  The specified module could not be found.
> 
> 
> Error: package ‘rJava’ could not be loaded
>> install.packages("rJava")
> Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
> (as ‘lib’ is unspecified)
> trying URL
> 'http://cran.rstudio.com/bin/windows/contrib/3.1/rJava_0.9-6.zip'
> Content type 'application/zip' length 759396 bytes (741 KB)
> opened URL
> downloaded 741 KB
> 
> 
> package ‘rJava’ successfully unpacked and MD5 sums checked
> 
> 
> The downloaded binary packages are in
> 	C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
>> library(rJava)
> Error : .onLoad failed in loadNamespace() for 'rJava', details:
>   call: inDL(x, as.logical(local), as.logical(now), ...)
>   error: unable to load shared object
> 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
>   LoadLibrary failure:  The specified module could not be found.
> 
> 
> Error: package or namespace load failed for ‘rJava’
>> library(xlsx)
> Loading required package: rJava
> Error : .onLoad failed in loadNamespace() for 'rJava', details:
>   call: inDL(x, as.logical(local), as.logical(now), ...)
>   error: unable to load shared object
> 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
>   LoadLibrary failure:  The specified module could not be found.
> 
> 
> Error: package ‘rJava’ could not be loaded

There are several possibilities, why your rJava does not find rJava.dll.
A good start give [1] to [3].

Did you have the right installation of JAVA itself?

I think, in your case, the JAVA installation itself should be the 64bit
version, and probably better version 1.8 than 1.7 [3] (someone please
correct me, if I am wrong here).

You get some hints about parameters with
R CMD javareconf --help

HTH.
Regards,
Rainer Hurling


[1]
http://cran.at.r-project.org/doc/manuals/r-release/R-admin.html#Java-support
[2]
http://cran.at.r-project.org/bin/windows/base/rw-FAQ.html#Loading-a-package-fails_002e
[3]
http://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r


> 
> 
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)



More information about the R-help mailing list