Xlsx package error in R

Hello.
I have installed xlsx package but it's shows following eoror

library(xlsx)
Error: package or namespace load failed for ‘xlsx’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Farhad/Documents/R/win-library/3.6/rJava/libs/i386/rJava.dll':
LoadLibrary failure: The specified module could not be found.
In addition: Warning message:
package ‘xlsx’ was built under R version 3.6.3
Can anyone help me ?

Hello lima,

Welcome to the forum! It is looking for an installation of java which it cannot find.

Best way to address this:

  1. Install Java
  2. Re-install rJava
  3. Try again to install xlsx. If it doesn't work you need to just change the directory so it is able to find the Java location.

(In the event of it not finding the location it will look something like this to set the directory:

Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jre7") # for 64-bit version 
Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\Java\\jre7") # for 32-bit version
library(rJava)

Should I install Java in PC?

you would need Java for R applications to access the Java runtime and work.

alternatively you could use an R package for reading excel that is not based on a java implementation.

I recommend readxl for reading excel into R

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