rJava on macOS with M2 processor - r

This question is similar to this one.
I'm pretty sure I have installed the correct R-4.2.2-arm64.pkg. Then, I don't understand why this error is appearing.
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 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib' (no such file), '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
My setup
MacBook Air
Chip: M2
macOS: Ventura 13.0.1
R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)
Rstudio version: 2022.7.2.576 (Spotted Wakerobin)
Any help will be appreciated

Related

Trouble running package "xlsx"

After installing R and RStudio on my new computer everything works fine, except the "xlsx" package. When trying to call it with library(xlsx) I get this error message:
Error: package or namespace load failed for ‘xlsx’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
The versioncommand produces the following output:
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.1
year 2019
month 07
day 05
svn rev 76782
language R
version.string R version 3.6.1 (2019-07-05)
nickname Action of the Toes
I see from similar questions that this problem might stem from the fact that the Java and the R versions don't correspond. But here, everything else works, and so far this seems to be the only package that produces this error message. I can't have more than one Java version installed at the time, can I? I have tried to reinstall the package, with the same result.
I have quite a lot of scripts where I have used the "xlsx" package, the synthax is different than the alternative package "readxl" and I would by far prefer to make the "xlsx" package work, rather than switching to "readxl". The "xlsx" package also comes with more options.
Any suggestions?

How to install rgl in OS X 10.14

I am running a vanilla copy of R 3.5.2:
> version
_
platform x86_64-apple-darwin18.2.0
arch x86_64
os darwin18.2.0
system x86_64, darwin18.2.0
status
major 3
minor 5.2
year 2018
month 12
day 20
svn rev 75870
language R
version.string R version 3.5.2 (2018-12-20)
nickname Eggshell Igloo
R is installed via Homebrew:
$ brew --version
Homebrew 1.9.2
Homebrew/homebrew-core (git revision de1ec; last commit 2019-01-15)
Homebrew/homebrew-cask (git revision 68a73e; last commit 2019-01-14)
I am trying to install the rgl package from within XQuartz 2.7.11 and the xterm application, and I get the following error:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/3.5/site-library/rgl/libs/rgl.so':
dlopen(/usr/local/lib/R/3.5/site-library/rgl/libs/rgl.so, 6): Library not loaded: #rpath/libc++.1.dylib
Referenced from: /usr/local/lib/R/3.5/site-library/rgl/libs/rgl.so
Reason: image not found
Error: package or namespace load failed for 'rgl':
.onLoad failed in loadNamespace() for 'rgl', details:
call: NULL
error: Loading rgl's DLL failed.
On MacOS, rgl depends on XQuartz, which you can download from xquartz.org.
Here is a screenshot to confirm that I am attempting the install from within the XQuartz xterm application:
Are there any additional steps required to configure Mac OS X 10.14 and XQuartz 2.7.11, which allows installation of rgl?

Can't load package xlsx after upgrading to Sierra

I recently updated to Sierra and it seems like I can't load packages that depends on rJava anymore.
For example:
library(xlsx)
Gives:
Loading required package: rJava
Loading required package: xlsxjars
JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
call: .jinit()
error: JNI_GetCreatedJavaVMs returned -1
Error: package or namespace load failed for ‘xlsx’
Here is my sessions info:
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12
And Java is updated to the latest version (8.111).
As far as I can understand from some similar posts the java directories is not configured correctly.
You can solve this with terminal commands that fix the wrongly configured directories and there are multiple posts that use this strategy. But this can be rather confusing.
A much easier strategy that worked for me is to use homebrew to install java. After installing Homebrew you can install java with the following commands
brew update
brew cask install java

Error: .onLoad failed in loadNamespace for 'rJava' in R's "XLConnect"

![enter image description here][1]![Hi All,
I'm working with the following R System:
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)][2]
I seem to be getting this error frequently on my laptop (description below).
HP G60 Notebook PC
Pentium(R) Dual-Core CPU T4400 # 2.20GHz
RAM 4GB
64-bit
I'm trying to use the function "loadWorkbook" to upload an excel file, but it returns the error in the image. I updated Java and R (recommendation from other posts) and re-ran the program, but it returns that error. I've also done install.packages(XL Connect, dependencies = TRUE).
Any help would be appreciated. I'll be glad to give more details if need be.
The error is the following:
Error: .onLoad failed in loadNamespace() for 'rJava'., details:
call: dirname(this$RuntimeLib)
error: a character vector argument expected
Also, the function works on my Surface 3 but not on my laptop. I'm sure it's something with my laptop, I just can't pinpoint it.

Error rJava 64bit R&Eclipse

I have been trying to switch to 64-bit environment but i get stuck with rJava not working.
I have followed thread where people where having the same problem and their solution (JDK, JVM.DLL, environment variables etc..) but i am still stuck
Here is the error i get:
Loading required package: Rbbg
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'H:/R/R-2.15.2/library/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified path is invalid.
Failed with error: 'package 'rJava' could not be loaded'
Here is R.version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 2
minor 15.2
year 2012
month 10
day 26
svn rev 61015
language R
version.string R version 2.15.2 (2012-10-26)
Thanks in advance
The problem because R can't find the jvm for the 64 architecture.
Normally if you have installed it you will get something like
C:\Program Files\Java\jre7\bin\server
Add this to your windows path and restart R.
Edit To ckeck if all things are right:
Type:
Sys.getenv()['PATH']
you get the environment variables inclusing the path for jvm.dll. If youd'ont have the jvm path here you need to add it using the usual Advanced System Settings method and restart your R console so this take effect.
Sys.getenv()['ProgramW6432']
You get C:\Program Files for the 64 archtitecture.

Resources