Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

rJava is not loading in R

$
0
0

So basically this is the error I'm having when calling rJava:

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

Below are some of the R & Terminal scripts that I ran while tackling the problem:

1) This returned error as well

$ sudo R CMD javareconf
Password:
Java interpreter : /usr/bin/java
Java version     : 13.0.1
Java home path   : /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

trying to compile and link a JNI program
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L. -ljvm
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/include/darwin  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L. -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: library not found for -ljvm
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [conftest.so] Error 1
Unable to compile a JNI program


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
Java library path:
JNI cpp flags    :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.

2)

> Sys.setenv(JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home')
> dyn.load('/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server/libjvm.dylib')

3)

$ sudo ln -f -s $(/usr/libexec/java_home)/lib/server/libjvm.dylib /usr/local/lib

In case this helps:

> Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH")
[1] "/Library/Frameworks/R.framework/Resources/lib:/Users/paulwoo/lib:/usr/local/lib:/usr/lib:::/lib:/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server"> Sys.getenv("DYLD_LIBRARY_PATH")
[1] "/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server"

Yet none of these solved the problem. I have reinstalled rJava package several times as well. My best guess is that this has something to do with mismatch between the versions, but I have no idea what to do.

Any other suggestions?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>