Loading R package xlsx: Error : .onLoad failed in loadNamespace() - r

I tried to load the R package xlsx:
library('xlsx')
But I got the following error:
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
call: .jinit()
error: Cannot create Java virtual machine (-1)
In addition: Warning message:
package ‘xlsx’ was built under R version 3.2.3
Error: package or namespace load failed for ‘xlsx’
My R-session aborts when I try .jinit()
Any help is much appreciated.
Edit:
I updated R Studio to the newest version and executed
update.packages(checkBuilt = TRUE)
but still got the following error:
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
call: .jinit()
error: Cannot create Java virtual machine (-1)
Error: package or namespace load failed for ‘xlsx’
Edit 2:
This question is still unsolved.
As Pascal in the comments below suggested I looked for the windows equivalent command of:
R CMD javareconf
After many hours of searching I still didn't found it.

I faced similar problem on Macbook. If you've upgraded Java recently, it is likely that you need to reconfigure.
For me, it got solved with,
step#1 sudo R CMD javareconf (On Windows, sudo not required. If you face "command not found" issue on Windows, try this)
step#2 install.packages("rJava",type='source') (inside R prompt)
Hope this helps!

In case you don't have PATH variable set up properly, try to override it by using
options(java.home="PATH TO jre")
This might fix some issues.

Related

rjags installation error, can't find JAGS path on Windows

I'm having an issue getting rjags to load & run. I can install rjags, but it doesn't run because it can't find JAGS. My versions are listed below and are all updated to the latest versions. I'm also using a Thinkpad.
JAGS Version: 4.3.0
RStudio Version: 2021.09.0 Build 351
Installation of rjags is okay using the following command:
install.packages('rjags',configure.args="--enable-rpath")
Error messages recopied below:
library(rjags)
Warning: package ‘rjags’ was built under R version 4.0.5
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: The environment variable JAGS_HOME is set to
C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0
but no JAGS installation can be found there
If I go to where JAGS is installed, the path is:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS
I used the above lines shared to try and solve this problem, but to no avail:
Sys.setenv(JAGS_HOME="C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0")
Error: unexpected '/' in "Sys.setenv(JAGS_HOME=C:/"
Corrected to:
Sys.setenv(JAGS_HOME="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS\JAGS-4.3.0")
Error: '\P' is an unrecognized escape in character string starting ""C:\P"
Corrected to:
Sys.setenv(JAGS_HOME="C:\ ProgramData\ Microsoft\ Windows\ Start Menu\ Programs\ JAGS\ JAGS-4.3.0")
This doesn't yield any errors, but when I try to load rjags I get the following:
library(rjags)
Warning: package ‘rjags’ was built under R version 4.0.5
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: The environment variable JAGS_HOME is set to
C: ProgramData Microsoft Windows Start Menu Programs JAGS JAGS-4.3.0
but no JAGS installation can be found there
This is the same as above, but the / are left out for some reason.
Unsure of what to try next, any thoughts/insight would be much appreciated! :)
This seems to be an issue others have faced too: rjags failed to load and R Failed to locate any version of JAGS
https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/060fd5c378/?limit=25
https://www.reddit.com/r/rstats/comments/pzto5t/rjags_is_my_enemy/
Though none of these solutions seem to be working (yet?).
Problem solved!
Both of you were right - JAGS was in an odd location, so I moved it to:
C:\Program Files\JAGS\JAGS-4.3.0
And then used the code (I think / is the same as \):
Sys.setenv(JAGS_HOME="C:/Program Files/JAGS/JAGS-4.3.0")
And now it works like a charm :)

rJava "EXTPR_PTR" procedure entry point not found in library

I'm attempting to install rJava as to use the package tabulizer. My steps so far has been to rund install.packages("rJava"), run Sys.setenv(JAVA_HOME="C:/Program Files/Java/jdk-15.0.1"), and then run library(rJava). When running the last command I first get a pop-up showing EXTPTR_PTR Entry Point for procedure not found (based on my hopeful translation), and then in console:
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: NULL
error: .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'D:/TidlPic/Eric/Documents/R/win-
library/4.0/rJava/libs/x64/rJava.dll'
I have made sure I have the latest version of both the JRE and JDK versions of Java, and that both them and R are the 64bit versions. I've also attempted at pointing the Java_Home path to either one of them, as well ast just ../Java, and they all return the same error. Any clues on what it is wrong? All help appreciated!
There was accidental breakage introduced by R 4.0.0 or R 4.0.1 which was fixed in R 4.0.2 and R 4.0.3. Are you by chance running 4.0.1? Upgrading would help.
The official word from one R Core member is to not use EXTPTR_PTR (see e.g. this list email). The current CRAN version of rJava should also be fine.
So in short: 'current' rJava with 'current' R should be fine.

R error loading package rJava and openNLP

I get this error message while trying to load the rJava or the openNLP packages through the function library(openNLP) or library(rJava):
Error: package or namespace load failed for ‘rJava’:
.onLoad in loadNamespace() for 'rJava' failed, details:
call: dirname(this$RuntimeLib)
error: a character vector argument expected
I have no problems loading other packages, e.g. NLP.
Does somebody know what the problem is?
I have updated the Java SE Development Kit and now I get no error message anymore. So this seems to be the solution for the problem.
I solved this problem by installing Java SE Development Kit 8.
Link for Download: http://www.oracle.com/technetwork/pt/java/javase/downloads/jdk8-downloads-2133151.html

Error: package ‘rJava’ could not be loaded when installing xlsx

Im trying to install the xlsx package. Installing works fine but when i load the library I get the following error:
> require(xlsx)
Loading required package: xlsx
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re- installing Java and make sure R and Java have matching architectures.
In addition: Warning messages:
1: package ‘xlsx’ was built under R version 3.2.3
2: package ‘rJava’ was built under R version 3.2.3
Failed with error: ‘package ‘rJava’ could not be loaded’
I googled around and say that installing the right version of Java might be the issue. However, when I downloaded the newest version and started a new r-session I still get the same issue.
Are there more people experiencing this issue? And some quick fix?
I am using Linux and when I update R or Java to use the rJava library (needed by xlsx) I need to run this commands form a shell (outside the R session)
sudo su -
R CMD javareconf
I hope this helps.

Error while installing R packages : Tcl/Tk support is not available on this system

I am using Linux- fedora 14 64 bit machine. While installing some of R packages , eg : DEGseq and sqldf , I am facing this error. I manually install all tcl and tk devel and core libraries using yum but the problem still persisting.
The error i am encountering while installing packages:
Warning: S3 methods ‘$.tclvar’, ‘$<-.tclvar’, ‘as.character.tclObj’, ‘as.character.tclVar’, ‘as.double.tclObj’, ‘as.integer.tclObj’, ‘as.logical.tclObj’, ‘as.raw.tclObj’, ‘print.tclObj’, ‘[[.tclArray’, ‘[[<-.tclArray’, ‘$.tclArray’, ‘$<-.tclArray’, ‘names.tclArray’, ‘names<-.tclArray’, ‘length.tclArray’, ‘length<-.tclArray’, ‘tclObj.tclVar’, ‘tclObj<-.tclVar’, ‘tclvalue.default’, ‘tclvalue.tclObj’, ‘tclvalue.tclVar’, ‘tclvalue<-.default’, ‘tclvalue<-.tclVar’, ‘close.tkProgressBar’ were declared in NAMESPACE but not found
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Tcl/Tk support is not available on this system
Error : package/namespace load failed for ‘tcltk’
Error : unable to load R code in package ‘gsubfn’
ERROR: lazy loading failed for package ‘gsubfn’
* removing ‘/home/xuserL/R/x86_64-unknown-linux-gnu-library/2.15/gsubfn’
ERROR: dependency ‘gsubfn’ is not available for package ‘sqldf’
* removing ‘/home/xuser/R/x86_64-unknown-linux-gnu-library/2.15/sqldf’
I am unable to find the solution even after googling about this error.
Please tell me the set of steps i need to follow in order to sort out this problem?
Thanks in advance :)

Resources