rJava can load in RStudio but not in R, OS is Ubuntu 14.04.1 LTS

心不动则不痛 提交于 2020-06-27 04:04:33

问题


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’

  1. OS version:

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.1 LTS Release: 14.04 Codename: trusty

  1. 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)

  1. 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"

  2. LD_LIBRARY_PATH from Terminal:

    $ echo $LD_LIBRARY_PATH

    dx@sd508:/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/lib/amd64/server

  3. JAVA_HOME from RStudio:

Sys.getenv("JAVA_HOME") [1] "/usr/lib/jvm/java-7-openjdk-amd64"

  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!