0

When I try to install the package xlsx I have the following error.

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 '/home/gallo/asn/.conda/envs/scRNAseq/lib/R/library/rJava/libs/rJava.so':
  libjvm.so: cannot open shared object file: No such file or directory
Traceback:

1. library(xlsx)
2. tryCatch({
 .     attr(package, "LibPath") <- which.lib.loc
 .     ns <- loadNamespace(package, lib.loc)
 .     env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
 . }, error = function(e) {
 .     P <- if (!is.null(cc <- conditionCall(e))) 
 .         paste(" in", deparse(cc)[1L])
 .     else ""
 .     msg <- gettextf("package or namespace load failed for %s%s:\n %s", 
 .         sQuote(package), P, conditionMessage(e))
 .     if (logical.return && !quietly) 
 .         message(paste("Error:", msg), domain = NA)
 .     else stop(msg, call. = FALSE, domain = NA)
 . })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. stop(msg, call. = FALSE, domain = NA)`

After Check Java Path in R, I try to reinstall rJava and then I check dynamic Library Path:

system("java -version")

Sys.setenv(JAVA_HOME = "/home/gallo/asn/.conda/envs/scRNAseq/lib/R/library/rJava/libs/rJava.so")

install.packages("rJava", type = "source")

Sys.setenv(LD_LIBRARY_PATH "/home/gallo/asn/.conda/envs/scRNAseq/lib/R/library/rJava/libs/rJava.so")

library(xlsx)

--> RETURN SAME PROBLEM

r2evans
  • 141,215
  • 6
  • 77
  • 149
ASN
  • 1
  • (1) Make sure you have `openjdk-#-jre-headless` (where `#` is the version number you need) installed in the base OS (not in R); (2) your second `Sys.setenv` is missing an `=`, it should have a parsing error. – r2evans Aug 18 '23 at 20:06
  • Can you load rJava itself with `library(rJava)`? – Dubukay Aug 18 '23 at 22:22
  • Conda R users should not use `install.packages()`, but rather stick to Conda Forge. Also PATH should never need to be manually manipulated. Everything Conda needs it will provide. See https://stackoverflow.com/a/69921221/570918 – merv Aug 18 '23 at 23:22
  • Also, Conda Forge is the most reliable source for R packages and for that reason Mambaforge base is what I recommend for new Conda installations (not Anaconda). – merv Aug 18 '23 at 23:23
  • @Dubukay When I load rJava appear this error: `library(rJava) Error: package or namespace load failed for 'rJava': .onLoad failed in loadNamespace() for 'rJava', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/home/gallo/asn/.conda/envs/scRNAseq/lib/R/library/rJava/libs/rJava.so': libjvm.so: cannot open shared object file: No such file or directory` – ASN Aug 19 '23 at 09:51
  • Yeah, so it'll be a problem with your Java installation process particularly, not xlsx. You may find more help searching for rJava install problems than xlsx, and when you're able to load rJava then xlsx should work without any problems. – Dubukay Aug 19 '23 at 17:41

0 Answers0