问题
I have rJava installed, it loads well in RStudio, but cannot load when I start R from Terminal, or from crontab. I've tried all possible ways I found online, what else can I do now?
0.1. Error message
library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/mnt/home/dx/R/x86_64-pc-linux-gnu-library/3.0/rJava/libs/rJava.so': libjvm.so: cannot open shared object file: No such file or directory Error: package or namespace load failed for ‘rJava’
- OS version:
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.1 LTS Release: 14.04 Codename: trusty
- JAVA version:
java version "1.7.0_75" OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~trusty1) OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
LD_LIBRARY_PATH from RStudio:
Sys.getenv("LD_LIBRARY_PATH") [1] "/usr/lib/R/lib:/lib:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server"
LD_LIBRARY_PATH from Terminal:
$ echo $LD_LIBRARY_PATH
dx@sd508:/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/lib/amd64/server
JAVA_HOME from RStudio:
Sys.getenv("JAVA_HOME") [1] "/usr/lib/jvm/java-7-openjdk-amd64"
- JAVA_HOME from Terminal:
$ echo $JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
回答1:
Is your Java executable on system path? You have set the JAVA_HOME
environment variable, but have you appended the bin
directory (underneath it) to the PATH
environment variable?
eg. like this: export PATH=$PATH:$JAVA_HOME/bin
libjvm.so
is part of Java installation, so it should be independent of the LD_LIBRARY_PATH
environment variable.
来源:https://stackoverflow.com/questions/28617617/rjava-can-load-in-rstudio-but-not-in-r-os-is-ubuntu-14-04-1-lts