Error rJava 64bit R&Eclipse - r

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.

Related

rJava on macOS with M2 processor

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

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

rJava loading error- "character vector expected"

I am using 64 bit windows 7 & 64 bit R 3.2.0. I have downloaded rJava package, but it is giving an error as follows.
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dirname(this$RuntimeLib) error: a character vector argument
expected In addition: Warning message: package ‘rJava’ was built under
R version 3.2.2 Error: package or namespace load failed for ‘rJava’
I searched stackoverflow for answers, and did the following:
1) Added the jvm.dll file to my PATH variable, i.e. in the following directory:
C:\Program Files\Java\jdk1.8.0_25\jre\bin\
2) I am using 64 bit R 3.2.0 & checked if the JVM version was 64 bit or not, typing the following on the command line:
java -d64 -version
It gave the following output:
C:\Users\xyz> java -d64 -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
So at least the JVM matches with R.
So what more needs to be done to make rJava work? I also checked my PATH variable and it seems okay.
I know this is way too late, but did you try switching R versions as a diagnostic step?
For RStudio 1.0.136: Tools -> Global Options... -> General: R version: Change - Choose 32 bit.
Changing versions worked for me and prompted me to revisit my java installation. (Ended up just using R32)
Got the same error with R64:
Loading required package: XLConnectJars
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dirname(this$RuntimeLib)
error: a character vector argument expected
Error: package ‘XLConnectJars’ could not be loaded
Was running RStudio on Windows 10 using machine's default R64.
Ya must specify where the jdk is. For example:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk1.8.0_161')
then it should work.

Resources