Apple M1 - Cannot Load rJava for xlsx package in R - java

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.

Related

Installing rJava on a Mac

I'm trying to install the rJava package for Rstudio on a Mac. I use the steps provided by this Github workshop. I ran in trouble with step 2:
#If you are using a Mac machine, an additional step may be needed before loading rJava package
#dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
library("rJava")
This is the R script I used with the console output:
> dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
> library("rJava")
Output:
> dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
Error in dyn.load("/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib") :
unable to load shared object '/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib':
dlopen(/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib, 0x0006): tried: '/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib' (no such file)
> library("rJava")
Error: package or namespace load failed for ‘rJava’:
.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)))

Macbook Pro M1 issues connecting to oracle database with R

I am using an M1 MBP running Monterey and trying to connect to an oracle database to pull data into R. Currently I am trying to setup RJDBC but am open to other options if there is something easier to use.
When I try to load RJDBC I am getting:
Loading required package: rJava
Error: package or namespace load failed for ‘rJava’:
.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')), '/usr/lib/libjli.dylib' (no such file)
Error: package ‘rJava’ could not be loaded
I have seen a few similar posts:
How to install rJava package in Mac with M1 architecture
Problem with R studio on Mac with Monterey and arm system
And am wondering what the best course of action here is. Would it be better to try and instal the arm version of java or the arm version of R?
JavaAppletPlugin no longer exists.
Java Applet technology has been retired, phased out across all platforms including macOS.
See Oracle white paper, Java Client Roadmap Update.
Contact the app publisher for an updated modern release. The release you have must be from many years ago.
Resolved by downloading ARM version of java:
https://www.oracle.com/java/technologies/downloads/#jdk17-mac

Having trouble loading rJava and xlsx on R studio keep getting same error message

Hello I am attempting to export some R files that were edited in R to excel. I am trying to install the package xlsx and rjava as they both are needed.
I have already tried to download Java into the file pathway but it will not let me since the folder already has files in it. So I did the next best thing and created a folder in hopes this would work but I keep getting the same error. I also have Rtools installed.
> install.packages("rJava")
Installing package into ‘C:/Users/Austin/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rJava_0.9-11.zip'
Content type 'application/zip' length 832080 bytes (812 KB)
downloaded 812 KB
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Austin\AppData\Local\Temp\RtmpcHsZaF\downloaded_packages
> library("rJava")
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Austin/Documents/R/win-library/3.6/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
Being able to export R files to excel

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