Problem with namespace installing rJava - r

I am installing rJava on a 64bit machine, running Windows XP, and am encountering the weirdest message. Below is the log. Has anyone seen this before? Thanks in advance.
> install.packages("rJava")
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.12/rJava_0.8-8.zip'
Content type 'application/zip' length 636680 bytes (621 Kb)
opened URL
downloaded 621 Kb
The downloaded packages are in
C:\Documents and Settings\wdeng\Local Settings\Temp\RtmpYb4lzb\downloaded_packages
> library("rJava")
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/PROGRA~1/R/R-212~1.0/library/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
Error: package/namespace load failed for 'rJava'

Looks like a garden-variety binary incompatibility to me.
The NAMESPACE is a red herring as it happens to load the dynamic library, and that's where the trouble lies.

Does the DLL file exist at that path? If it does, than maybe it's one of its dependencies that's missing. Try http://www.dependencywalker.com/ to identify which one.
After that...?

Related

Using any Library to Read Excel files from R

I have R installed in a usb stick (since I'm using work computer and don't have Admin access to install software), and so far I've been having to resort to read.csv() since I can't use any library to read excel files.
For example, XLConnect gives the problem of :
>Error: package or namespace load failed for ‘XLConnect’:
>> .onLoad failed in loadNamespace() for 'rJava', details:<br>
>> call: inDL(x, as.logical(local), as.logical(now), ...)<br>
>> error: unable to load shared object 'D:/R/R-4.0.2/library/rJava/libs/x64/rJava.dll':<br>
> LoadLibrary failure: %1 is not a valid Win32 application.<br>
>In addition: Warning message:
>package ‘XLConnect’ was built under R version 4.0.3
It seems that these libraries (readxl, xlsx, or XLConnect) are failing because they don't know where I have Java installed. So, I also did this:
Sys.setenv(JAVA_HOME='C:\Program Files (x86)\Java\jre1.8.0_131\bin')
but, to no avail. (that advice I got it from https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/)
If someone knows how to read excel files using R from a memory stick - I would really appreciate if they can point north to me.
btw, this is the error when loading xlsx library:
> library(xlsx)
>Error: package or namespace load failed for ‘xlsx’:
>> .onLoad failed in loadNamespace() for 'rJava', details:<br>
>> call: inDL(x, as.logical(local), as.logical(now), ...)<br>
>> error: unable to load shared object 'D:/R/R-4.0.2/library/rJava/libs/x64/rJava.dll':<br>
>> LoadLibrary failure: %1 is not a valid Win32 application.
<br>
>In addition: Warning message:<br>
>package ‘xlsx’ was built under R version 4.0.3
and this is the error when trying to read an excel file with readxl (no problem when loading):
>*Error in loadNamespace(name) : there is no package called ‘cli’*
This is it, this did it:
"You may want to check out this posting: stackoverflow.com/questions/29254067/…" – SteveM 16 hours
Thank you kind stranger.

Package ("qdap") fails to load with multiple errors

While installing qdap I have not faced any errors. But when loading the library, I face the follwing errors.
> library(qdap)
Loading required package: qdapDictionaries
Loading required package: qdapRegex
Loading required package: qdapTools
Loading required package: RColorBrewer
Error: package or namespace load failed for ‘qdap’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
I read in another question that we need to install the JAVA 64bit (as my Win 10 is 64-bit) and load the JAVA home. So I downloaded the 64-bit java file and also set the JAVA_HOME to the directory.
> Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jre1.8.0_231')
> library(qdap)
Error: package or namespace load failed for ‘qdap’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Admin/Documents/R/win-library/3.6/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
I have uninstalled and installed the latest R software (3.6.2; I've checked both 32-bit and 64-bit options), restarted R-studio as well, to no avail.
The issue is fixed. Although I'm not 100% sure what solved, here is what i have done.
The error %1 is not a valid Win32 application. is indicating 32-bit.
So I started Rgui console (32-bit) (opened from the directory C:\Program Files\R\R-3.6.2\bin\i386 ). The library(rJava) command works well and so does library(qdap).
Then I changed the options in Rstudio to choose 32-bit R [Tools -> Options -> General]. But setting this will impact high memory consuming executions. After a while (when I started facing memory issues), I switched the RStudio to use the 64-bit R.
The error did not appear after that and I was able to load the 'qdap' library.

Unable to install library functions of qdap on mac

I'm working on a project on R studio and I got a error message while installing qdap on my mac and running the library function.
And this is what I got.
install.packages('qdap')
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/qdap_2.3.0.tgz'
Content type 'application/x-gzip' length 4164745 bytes (4.0 MB)
==================================================
downloaded 4.0 MB
The downloaded binary packages are in
/var/folders/0v/c58lzwxd513g64xxc0gd85rm0000gn/T//RtmphbntNA/downloaded_packages
> library('qdap')
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.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
I found that the problem is that R is not able to locate Java_home correctly.
Steps to follow:
Download and install Java JDK if you haven't already done so.
In Terminal, find java location by typing which java
Set JAVA_HOME in R as Sys.setenv("JAVA_HOME" = 'your java location such as /usr/bin/java').
Try reinstalling the packages openNLP, rJava, and qdap.

RJava and XLConnect in RStudio not loading

First the tech specs of what I am using:
RStudio 0.98.983
R 3.1.1 (64 Bit)
Windows 8.1
When trying to load XLConnect I receive the following error
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package or namespace load failed for ‘XLConnect’
When trying to load RJava I receive the following error
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package or namespace load failed for ‘rJava’
I've checked to make sure the newest updates are installed from CRAN. However I am out of ideas and new to R. Does anyone know how to fix this?
Here is what I posted before:
Meanwhile, I am right now having the problem with the relenium package, which can't locate rJava.
Version mismatches can bedevil you. Check that if your version of R is 32 byte, so must your Java version be. Or, 64 byte must match 64 byte.
Second, I ended up adding to my PATH (I am on Windows 8) the location of the jv.dll file that XLConnect needs (I think that was the name of the file). I found the PATH through Control Panel and System Environment (and maybe more).
Third, the Java site will verify that you have Java installed.
Fourth, with the matching architecture and the PATH pointing to the needed .dll file, I rebooted and it all worked.
Good luck.

Error loading rJava in R (Ubuntu 12.04)

I had some issues installing rJava first. Then I found this solution.
Unfortunately I get following error, when loading the package:
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/informatik2/students/home/1jendryc/R/x86_64-pc-linux-gnu-library/3.1/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: package or namespace load failed for ‘rJava’
Still this file exists and even the path is correct
~/R/x86_64-pc-linux-gnu-library/3.1/rJava/libs$ ls
rJava.so
So I tried that approach, but it didn't worked.
I have no possibility to get root easily, cause I am working at my university at a pool computer.
Cheers.
Your issue is something different. What message says is that it can't find "libjvm.so". You need to properly configure Java, rJava and R. Take a look here
http://www.owsiak.org/?p=3671
where all the caveats are listed when it comes to working with R and Java.

Resources