Unable to use xlsx

Hi, I'm new to R and trying to use xlsx. I can't get it to run - please see the below error message. I've tried to install a recent java version but it didn't seem to fix the problem. I am using 10.13.6 Mac High Sierra OS .Could anyone help? Thank you.

library(xslx)

Error in library(xslx) : there is no package called ‘xslx’

install.packages('xlsx',repos='http://cran.r-project.org')

trying URL 'http://cran.r-project.org/bin/macosx/el-capitan/contrib/3.6/xlsx_0.6.1.tgz'
Content type 'application/x-gzip' length 461752 bytes (450 KB)

downloaded 450 KB

The downloaded binary packages are in
/var/folders/rq/5mw7b6_j4wj18s5vvdd8d36r0000gn/T//RtmpHqeU5G/downloaded_packages

library(xlsx)

Unable to find any JVMs matching version "(null)".
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.6/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/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.6/Resources/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning message:
In system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1
No Java runtime present, try --request to install.

You can try running this command on a system terminal and rebooting your machine.

sudo R CMD javareconf

Thank you, I tried entering that command in R but got the following error. I wasn't sure what you meant by system terminal - is there a location on a Mac where you mean I should be entering that?

sudo R CMD javareconf
Error: unexpected symbol in "sudo R"

Yes, on the terminal

https://macpaw.com/es/how-to/use-terminal-on-mac

Thank you - I entered the command there and got the following message:
Java interpreter : /usr/bin/java
No Java runtime present, requesting install.

*** Java interpreter doesn't work properly.

Then you haven't java properly installed

I do have Java, I just checked it, updated to the latest version and restarted the computer.
I then opened R and retried opening xlsx and got the following error message again:

library(xlsx)

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.6/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/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.6/Resources/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning message:
In system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.

On my project I wanted to be able to read Excel as inputs, but I wanted to avoid java dependency.
I found this package worked very well for my needs:

Thank you so much! I just used that package to successfully import an excel file with no java issues.
Thanks again!

You're welcome smatt

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