Error while loading rJava

SWR picture SWR · Nov 15, 2012 · Viewed 13.9k times · Source

I get an error when I'd like to load rJava. JDK is installed. (I run R on a CentOS VM (cloudera demo vm cdh3u4))

> library(rJava)

Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/home/cloudera/R/x86_64-redhat-linux-gnu-library/2.15/rJava/libs/rJava.so':
  libjvm.so: cannot open shared object file: No such file or directory
Error: package/namespace load failed for ‘rJava’

Is there something wrong with LD_LIBRARY_PATH settings? If yes, how can I fix that? I need rJava running that to install rhdfs later.

Some more information (if needed):

[cloudera@localhost ~]$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

Answer

Tejus Prasad picture Tejus Prasad · Sep 19, 2014

For Ubuntu, oracle-java (7/8) installed. It'll be at this location /usr/lib/jvm and sudo access is required.

Create the file /etc/ld.so.conf.d/java.conf with the following entries:

/usr/lib/jvm/java-8-oracle/jre/lib/amd64
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server

(Replace java-8-oracle with java-7-oracle or java-7-openjdk-amd64 depending on your java version)

Then:

sudo ldconfig

Restart RStudio and then install the rJava package.