So I have tried the previously proposed answer to my question. but I am still having the same error message:
I am trying to load the rJava
library in R
I had the same problem and, as suggested in previous comments, I manually installed the 64-bit version, selecting it here. I only had to restart R. It worked perfectly.
For me the problem was caused because a 32-bit Java version was installed on the system, but I was running 64-bit version of R
. Installing the 64-bit Java version solved the problem with rJava
namespace environment. Because I am running a 32-bit browser I had to manually download the 64-bit Java version.
What worked for me is explained here. Essentially, do sudo R CMD javareconf
in the terminal and reboot.
I'll just add one more possible solution, since I tried all of the suggestions listed above (reinstalling Java x64, installing both JDK & JRE, setting JAVA_HOME, sudo R CMD javareconf
or even sudo R CMD javareconf -n
seen elsewhere, and more) but none of them worked and I kept getting the following error:
> library(rJava)
Error: package or namespace load failed for ‘rJava’:
.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.6/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.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/rJava/libs/rJava.so
Reason: image not found
There were 2 possible solutions that helped me get through this error:
/Library/Java/JavaVirtualMachines/
) where you'll find a folder titled something like "jdk-13.0.1.jdk" (depending on your JDK version). Changing its name to "jdk-11.0.1.jdk" (or whatever is mentioned in your error) should solve your problem.But maybe even better is to do the following instead:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so
, open it in a text editor (such as TextEdit) and change "jdk-11.0.1.jdk" to "jdk-13.0.1.jdk" (or whatever is the folder referenced in your error and what is actually in your Java folder, respectively).Either way worked for me but the latter looks a bit cleaner to me. Hope this helps someone!
I had the same problem.
From what I've understood this was due to two reasons: a) R being 64-bits and Java being on 32-bits, b) R being installed in D:\Documents and Java being installed in C:\Programmes.
I've solved the issue by: