1

I am trying to install rJava and RJDBC on Databricks (from notebook).

I ran recommended lines:

%sh ls -l /usr/bin/java ls -l /etc/alternatives/java ln -s /usr/lib/jvm/java-8-openjdk-amd64 /usr/lib/jvm/default-java R CMD javareconf 

Installation went fine, but when I try

library(rJava) 

I get this error:

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 '/local_disk0/.ephemeral_nfs/envs/rEnv-83cc4969-e3a2-430d-83c5-b43067bdea17/rJava/libs/rJava.so': libjvm.so: cannot open shared object file: No such file or directory Error: package or namespace load failed for ‘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 '/local_disk0/.ephemeral_nfs/envs/rEnv-83cc4969-e3a2-430d-83c5-b43067bdea17/rJava/libs/rJava.so': libjvm.so: cannot open shared object file: No such file or directory 

What do I do in this case?

UPDATE

Following the link rJava prerequisites after installing rJava and RJDBC I ran

dyn.load('/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so') library(rJava) 

and got the following output:

Error in dyn.load("/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so") : unable to load shared object '/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so': /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so: cannot open shared object file: No such file or directory Error in dyn.load("/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so"): unable to load shared object '/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so': Error in dyn.load("/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so"): unable to load shared object '/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so': /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so: cannot open shared object file: No such file or directory 

Another update

The following line is not just necessary to verify installation, it is a part of installation and it is possible that path is different. Here is pass that worked for me:

dyn.load('/usr/lib/jvm/zulu11-ca-amd64/lib/server/libjvm.so') 

And here is some philosophy behind it.

"rJava uses JNI to hook into the JVM. For JNI to work, it needs access to the shared library. dyn.load is a r function that helps loads native shared object libraries (libjvm.so) into the namespace so any functions that need to call into java can be executed"

6
  • 1
    What's the point of the 'ls` calls? Are you supposed to use the output from them or are there files you need to confirm exist? Commented Mar 3, 2023 at 18:07
  • @Marcus, I have no idea, but I took it from here: learn.microsoft.com/en-us/azure/databricks/kb/r/… Commented Mar 3, 2023 at 18:10
  • I'm not sure if it would do something different in a bash script (can't claim to be an expert on bash scripts), but just listing out files with ls seems weird. Are you able to execute the dyn.load line with no errors? Commented Mar 3, 2023 at 18:16
  • 1
    it could be that the pass to Java installation has changed - check that output of ls commands points to /usr/lib/jvm/java-8-openjdk-amd64 Commented Mar 4, 2023 at 12:53
  • @Marcus, I ran dyn.load and posted update above. Commented Mar 14, 2023 at 14:45

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.