Error while loading rJava

centos, cloudera, java, r, rjava

Solution

Getting rJava to work depends heavily on your computers configuration. The following is working at least on a windows platform. You could try and check, if this will help you on your platform, too.

- You have to use the same 32bit or 64bit version for both: R and JDK/JRE. A mixture of this will never work (at least for me).

If you use 64bit version make sure, that you do not set JAVA_HOME as a enviorment variable. If this variable is set, rJava will not work for whatever reason. You can check if your JAVA_HOME is set inside R with:

Sys.getenv("JAVA_HOME")

If you need to have JAVA_HOME set (e.g. you need it for maven or something else), you could deactivate it within your R-session with the following code before loading rJava:

if (Sys.getenv("JAVA_HOME")!="")
  Sys.setenv(JAVA_HOME="")
library(rJava)

This should do the trick in most cases. Furthermore this will fix issue Using the rJava package on Win7 64 bit with R, too. I borrowed the idea of unsetting the enviorment variable from R: rJava package install failing.

Problem

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) ```

Original source

Related problems