I try to load rJava in Rstudio Server 0.99.467 and Revolution Analytics Open R 3.2.0 (which is mostly standard R 3.2.0 with some additional packages) and I receive following error
> require(rJava)
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/usr/lib64/RRO-3.2.0/R-3.2.0/lib64/R/library/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
I'm using Centos 6.5 and Oracle Java 1.8 JDK
[root@server ~]# java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
I've googled the problem and one of the solutions was to set JAVA_HOME to empty string, however I've got it already set to that value.
> Sys.getenv("JAVA_HOME")
[1] ""
Also I've got two library paths if it may be the cause of the problem:
> .libPaths()
[1] "/home/kjedrzejewski/R/x86_64-unknown-linux-gnu-library/3.2"
[2] "/usr/lib64/RRO-3.2.0/R-3.2.0/lib64/R/library"
When I try to load this package in R console in bash no such error appear.
Everything started to work when as root I've run commands:
I'm not sure what exactly helped.
In my case the problem was that $LD_LIBRARY_PATH, as it was accessed by Rstudio (
Sys.getenv('LD_LIBRARY_PATH')
), was pointing to a different java version than I was using.