Package xlxs installation in R has issues - java

When trying to install package xlxs in R I get the following error.
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Not sure what to do. I have tried reinstalling Java and still get the same error.
I have R 3.12 on a windows 10 computer.
Any advice is welcome,
Thanks

Error: package or namespace load failed for ‘xlsx’:
.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.
The error normally occurs when the architectures(32/64 bit) of java and r does not match.
In order to check the version of java, type java -version in cmd.
You can follow below given steps:
Rstudio > tools > global options > general settings > R-version > change (to the architecture same as that of java) > apply
And you're good to go.

Related

Apple M1 - Cannot Load rJava for xlsx package in R

I am currently working on an assignment that requires me to utilize the xlsx package in R. I have installed both "xlsx" and "rJava" packages, and have installed the most recent edition of Java to my computer.
However, when I try to load the "xlsx" package, I receive the following error:
enter image description here
> library(xlsx)
Error: package or namespace load failed for ‘xlsx’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(jli, FALSE)
error: unable to load shared object '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib':
dlopen(/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib, 0x000A): tried: '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
Any suggestions of how to fix this so I am able to use the xlsx package?
Thanks.
Tried searching for solutions that suggested I used a different non-Java based package to open the files, read it may be M1 Mac incompatible with Java.

How to handle a Java-error in an R-code on MacOSX?

When running my R-code using Shiny I get the following error message, only on my Mac (Catalina, V 10.15.1) but not on Windows:
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Warnung in system("/usr/libexec/java_home", intern = TRUE)
Ausführung von Kommando '/usr/libexec/java_home' ergab Status 1
Fehler: package or namespace load failed for ‘xlsx’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: kann shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so' nicht laden:
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
As my code is very extensive and long I cannot post it on here.
However, I would appreciate any help as I am still a beginner. Thank you!
MacOS X does not come with Java Development Kits (JDKs) pre-installed.
I recommend installing via HomeBrew then run the command:
brew cask install java and it will install the latest Oracle JDK and sort out any config for you.
Once you have the JDK, try running your R-Code again, it should be working fine and you should not see the Unable to find any JVMs error.

Cannot get rJava to work properly in MacOS 10.14

I am trying to code using the rSymPy package. When I type in library(rSymPy) I get the following warnings:
> library(rSymPy)
Loading required package: rJython
Loading required package: rJava
Loading required package: rjson
Warning messages:
1: package ‘rJava’ was built under R version 3.4.4
2: package ‘rjson’ was built under R version 3.4.4
This is fine because in theory my code should still work. However, when I try running my function which uses the sympy() command I get the following error:
> moment_generating_function(12)
Show Traceback
Error in .jcheck() : No running JVM detected. Maybe .jinit() would help.
I then run .jinit() which produces no output. Running my code again, I now get the following error
Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), :
java.lang.NullPointerException
I have tried reinstalling my JDK and tried running "r cmd javareconf;" in my terminal multiple times. I would just code this directly in Python but unfortunately my assignment requires I use the rSymPy package in R. I would greatly appreciate any help with this.

R error trying to load qdap package

So I am trying to run the
library(ggplot2)
library(qdap)
but this error keeps coming up:
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Error: package or namespace load failed for ‘qdap’:
.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.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning message:
running command '/usr/libexec/java_home' had status 1
I am using R in Rstudio on a mac, and I've trawled through quite a few similar questions but none seem to work. I am quite new to using R and any help would be great thanks.
I tried using
install.packages("openNLPdata")
and this showed up which I think is a good thing
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/openNLPdata_1.5.3-4.tgz'
Content type 'application/x-gzip' length 7323402 bytes (7.0 MB)
==================================================
downloaded 7.0 MB
The downloaded binary packages are in
/var/folders/h5/_5bjqp9j0g5gqr1794sw1xwh0000gn/T//RtmpaknsV6/downloaded_packages
But the error still occurs.
Thanks in advance
It seems like that package might need rJava to run, which may not be loaded in your environment. Try:
install.packages('rJava')
library('rJava')

R on Windows 10, rcmdr 'hasjava' error

I am trying to run biodiversity r in r studio with the biodiversity rgui which links up to the rcmdr. I have tried every help forum to find an answer but come up with nothing. I reinstalled R, R studio, updated all packages, installed rjava and javagd and still it refuses to work. I am at wits end!!! I cannot find anything about 'hasjava' and I have updated and installed java already.
Below is copy pasted from the console.
Restarting R session...
> library("BiodiversityR", lib.loc="~/R/win-library/3.2")
Loading required package: tcltk
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.3-0
BiodiversityR 2.5-3: use function 'BiodiversityRGUI()' to launch the BiodiversityR Graphical User Interface
> library("rJava", lib.loc="~/R/win-library/3.2")
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.
Error: package or namespace load failed for ‘rJava’
> BiodiversityRGUI()
Sourced: BiodiversityGUI.R
Error : .onAttach failed in attachNamespace() for 'Rcmdr', details:
call: eval(expr, envir, enclos)
error: could not find function "hasJava"
Error: package or namespace load failed for 'Rcmdr'
This problem has nothing directly to do with Windows or with Java.
The Rcmdr package no longer uses Java, and the function hasJava(), which was defined in and exported by the Rcmdr, no longer exists. Apparently BioDiversityR uses this function and needs to be updated appropriately.
You might report your problem directly to the maintainer of BioDiversityR.
I hope this help,
John

Categories

Resources