I have been reading up on examples and cannot figure out the solution. I also had IT come by and they can't figure out why it isn't working also.
I am trying to use the 'rJava' package from R.
I uninstalled RStudio and R to get the latest versions.
Here is what I did:
install.packages('rJava')
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rJava_0.9-9.zip'
Content type 'application/zip' length 720033 bytes (703 KB)
downloaded 703 KB
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Temp\RtmpSyCpeu\downloaded_packages
Then when I run below, this is what shows up:
library(rJava)
This same error message happens after I uninstalled RStudio and R.
When I click ok, below is the error that comes up.
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/nicknaue/Documents/R/R-
3.4.3/library/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
To try and solve for this, we downloaded the latest Java and also got a file from another program with the same name: jvm.dll and put it in the same file path. No luck also.
Has anyone come across this issue before?
Also, something weird, I have another computer where I tried this on and no errors came up.
I know there have been posts on this but I feel like I have tried everything at this point.
Figured out the answer from this link: Unable to load rJava on R
The issue was that I had 64-bit R and 32 bit Java. The two were not compatible before. You need 64 bit Java in order to run rJava if you have 64 bit R.
Related
I am working with R 4.2.1, 64bit, Windows 10.
while calling library rsubgroup, I get an error:
library(rsubgroup)
Loading required package: foreign
Error: package or namespace load failed for ‘rsubgroup’:
.onLoad failed in loadNamespace() for 'rsubgroup', details:
call: .jinit(parameters = parameters)
error: Unable to create a Java class loader.
rJava loads without problems.
I have installed Java 1.8.0_341 and JDK jdk-18.0.2
I have set-up manually JAVA_HOME and PATH variables.
Any hints what can go wrong with .jinit?
many thanks!
Solved, caused by my comp installation: R is installed in C:.../ProgramFiles that is write-protected (accessible only by "admin"); rJava and rsubgroup installed in the ...Users personal library. While moving all installation (core R, libraries) to writable disk, all starts to work. Apologies for this dumb question but I leave it here - perhaps could help somebody in future...
I have tried to call the library xlsx, since I want to save data in multiple-sheets excel files, but I got a Java-related error. Even when I run library(rJava) I have this error code:
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/me/Documents/R/win-library/4.0/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
The solutions I have found online are quite old and none helped to solve the issue: I have tried to reinstall Java 64 bit on my OS (Windows 10-64bit), and the package rJava, I have tried to set Java home with Sys.setenv(JAVA_HOME="C:\Program Files\Java\jre1.8.0_271\") without success. I use R 64 bit.
Do you have any suggestions?
Finally, the solution reported here worked for me. The most important thing is to download the offline version of Java
Cannot install R package xlsx.
I have previously used the package on other PCs and had no trouble with it whatsoever, but am having difficulty with a new PC. From what I can tell the issue is something to do with Java. Currently tried:
Downloading Java Development Kit
Downloading JRE
Editing environment variables to point to the right Java (for both of the above)
Running through the R console (both 32 and 64 bit)
Uninstalling and reinstalling Rstudio / R
install.packages("xlsx")
`Installing package into ‘C:/Users/Fred Goktas/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
xlsx 0.5.7 0.6.1 FALSE
installing the source package ‘xlsx’
trying URL 'https://cran.rstudio.com/src/contrib/xlsx_0.6.1.tar.gz'
Content type 'application/x-gzip' length 315441 bytes (308 KB)
downloaded 308 KB
* installing source package 'xlsx' ...
** package 'xlsx' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
* installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Fred Goktas/Documents/R/win-library/3.3/rJava/libs/i386/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Fred Goktas/Documents/R/win-library/3.3/xlsx'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.3/bin/x64/R" CMD INSTALL -l "C:\Users\Fred Goktas\Documents\R\win-library\3.3" C:\Users\FREDGO~1\AppData\Local\Temp\RtmpYLz0xk/downloaded_packages/xlsx_0.6.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status
Package should install without any troubles.
Unless you have no compelling reason to use xlsx, I would suggest you consider readxl because it has no external dependencies.
I have tried to install the R package JavaGDon MacOS 10.14.6. My R version is 3.6.1. When I do instal.packages there is apparently no error, but when I do in R console:
library(JavaGD)
Error: package or namespace load failed for ‘JavaGD’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/JavaGD/libs/JavaGD.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/JavaGD/libs/JavaGD.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/JavaGD/libs/JavaGD.so
Reason: image not found
It should work fine in macOS 10.14.
However, make sure your R and Java environments are correctly configured.
It might be a little bit of struggle to properly configure Java in R.
I suggest to start with simple Java code:
http://www.owsiak.org/r-java-11-and-making-sure-you-can-load-rjava/
to make sure you can actually use Java inside R.
In some cases it might be required to rebuild rJava package.
http://www.owsiak.org/r-3-4-rjava-macos-and-even-more-mess/
Anyway, I guess that first step is to make sure you can actually bind these two worlds.
I was just installing an R package that appears to reference Java. I received the following error.
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.
I reinstalled Java on my computer to the latest version, and I still receive this error. What do I need to do to get R, or is it RStudio, to recognize my computer installation of Java?
Well, on a lark, I googled the error, and found this answer:
https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/
Apparently, have to make sure 64-bit version is loaded. Requires manual intervention...