Getting error while installing the packages

Hi, I am trying to install package
install.packages("xlsx")
but getting below error

Error: package 'rJava' could not be loaded
Execution halted
ERROR: lazy loading failed for package 'xlsxjars'

  • removing 'C:/Users/AppData/Local/anaconda3/envs/rstudio/lib/R/library/xlsxjars'
    Warning in install.packages :
    installation of package ‘xlsxjars’ had non-zero exit status
    ERROR: dependency 'xlsxjars' is not available for package 'xlsx'
  • removing 'C:/Users/AppData/Local/anaconda3/envs/rstudio/lib/R/library/xlsx'
    Warning in install.packages :
    installation of package ‘xlsx’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\AppData\Local\Temp\Rtmp6Zaax1\downloaded_packages’

Even I tried to install 'rjava', 'xlsxjars' packages but not getting installed

Hi, welcome to the forum.

I am not a Windows user but my guess would be that either you do not have Java installed or that you may need to update your version of Java.

Can you show the actual installation errors? Or the full installation output if you are unsure?

In any case I would try running

R  CMD javareconf

to make sure that Java is installed and R is configured to use it.

Java is updated version is already installed in my system and R is configured to use it

Can you show the output of

system("R CMD javareconf")

and also the full output of a failed installation?

install.packages("xlsx")

also installing the dependency ‘xlsxjars’

Warning in install.packages :

unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.6:

cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/PACKAGES'

installing the source packages ‘xlsxjars’, ‘xlsx’

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

trying URL 'https://cran.rstudio.com/src/contrib/xlsx_0.6.5.tar.gz'

Content type 'application/x-gzip' length 489493 bytes (478 KB)

downloaded 478 KB

  • installing source package 'xlsxjars' ...

** package 'xlsxjars' successfully unpacked and MD5 sums checked

** using staged installation

** R

** inst

** byte-compile and prepare package for lazy loading

Error: package or namespace load failed for 'rJava':

.onLoad failed in loadNamespace() for 'rJava', details:

call: inDL(x, as.logical(local), as.logical(now), ...)

error: unable to load shared object 'C:/Users/ABC/AppData/Local/anaconda3/envs/rstudio/lib/R/library/rJava/libs/x64/rJava.dll':

LoadLibrary failure: %1 is not a valid Win32 application.

Error: package 'rJava' could not be loaded

Execution halted

ERROR: lazy loading failed for package 'xlsxjars'

  • removing 'C:/Users/ABC/AppData/Local/anaconda3/envs/rstudio/lib/R/library/xlsxjars'

Warning in install.packages :

installation of package ‘xlsxjars’ had non-zero exit status

ERROR: dependency 'xlsxjars' is not available for package 'xlsx'

  • removing 'C:/Users/ABC/AppData/Local/anaconda3/envs/rstudio/lib/R/library/xlsx'

Warning in install.packages :

installation of package ‘xlsx’ had non-zero exit status

The downloaded source packages are in

‘C:\Users\ABC\AppData\Local\Temp\RtmpKMiMSt\downloaded_packages’

Can you show the output of this?

system("R CMD javareconf")

output <- system("R CMD javareconf", intern = TRUE)
Warning message:
In system("R CMD javareconf", intern = TRUE) :
running command 'R CMD javareconf' had status 1
cat(output, sep = "\n")
'javareconf' is not recognized as an internal or external command,
operable program or batch file.

1 Like

Two more things. You are using R 3.6, which is very old. CRAN has (old) binary packages for it, but at a different repo, so you'd need to use that to get binary packages:

options(repos = c(CRAN = "https://cran-archive.r-project.org/"))

Most importantly, you seem to be using CRAN R with an active conda, and that does not work. You need to either

  1. deactivate conda when you are using CRAN R, or
  2. install R and all R packages from conda.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.