Issues with installing the "xlsx" package

Hi, I am trying to install the xlsx package to enable a conversion of my PDF into Excel. I have already installed pdftools and pdftables. However, my R Studio is giving trouble to install xlsx package. I get the following message after install.packages("xlsx"):

Installing package into ‘/Users/mohitarora/Library/R/3.5/library’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
     binary source needs_compilation
xlsx  0.6.3  0.6.5             FALSE

installing the source package ‘xlsx’

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 ‘xlsx’ ...
** package ‘xlsx’ successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
  Reason: image not found
ERROR: lazy loading failed for package ‘xlsx’
* removing ‘/Users/mohitarora/Library/R/3.5/library/xlsx’
Warning in install.packages :
  installation of package ‘xlsx’ had non-zero exit status

And when I call the library(xlsx), I get the following message:

Error: package or namespace load failed for ‘xlsx’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
  Reason: image not found

Any help/ideas as to how can I fix this error?

I also tried what was listed on an older post (Trouble installing package "xlsx") but the method suggested here - the following two lines of code -

debug(utils:::unpackPkgZip)
install.packages("xlsx")

This also did not work because R is throwing an error with the first line "debug". This is the error -
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object 'unpackPkgZip' not found

Any help would be appreciated. Thanks

Mohit

Do you have a matching architecture installation of Java in your system? If so, try running this command from a system terminal sudo R CMD javareconf and then reinstalling rJava.

This topic was automatically closed 21 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.