我通过运行以下命令安装了 rJavaR CMD javareconf -e | tee javareconf.out
cat javareconf.out
Java interpreter : /usr/lib/jvm/java-8-oracle/jre/bin/java
Java version : 1.8.0_201
Java home path : /usr/lib/jvm/java-8-oracle
Java compiler : /usr/lib/jvm/java-8-oracle/bin/javac
Java headers gen.: /usr/lib/jvm/java-8-oracle/bin/javah
Java archive tool: /usr/lib/jvm/java-8-oracle/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I/usr/lib/jvm/java-8-oracle/include -I/usr/lib/jvm/java-8-oracle/include/linux
detected JNI linker flags : -L/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/lib/jvm/java-8-oracle/include -I/usr/lib/jvm/java-8-oracle/include/linux -fpic -g -O2 -fdebug-prefix-map=/build/r-base-1SEA_D/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server -ljvm -L/usr/lib/R/lib -lR
The following Java variables have been exported:
JAVA_HOME JAVA JAVAC JAVAH JAR JAVA_LIBS JAVA_CPPFLAGS JAVA_LD_LIBRARY_PATH
Running: /bin/bash
我也在 R 中安装了 rJava 包 ( install.packages("rJava")
)。现在,我可以从 R 使用 rJava,但不能从 RStudio 使用。
我尝试改变 LD_LIBRARY_PATH 以包含 Java lib,然后从 RStudio 内部安装 rJava,但没有成功。export LD_LIBRARY_PATH="/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server:$LD_LIBRARY_PATH"
有趣的是,如果我用sudo rstudio kill-all
它打开 RStudio,它可以像在 R 中一样工作,但如果我通过单击 Dock 中的图标打开 RStudio,我会出现以下错误:
> library(rJava)
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/kzkedzierska/R/x86_64-pc-linux-gnu-library/3.5/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
我尝试重新安装 RStudio(sudo apt purge rstudio
并手动删除主目录中留下的 .rstudio 目录)但这没有帮助......
知道该如何修复此问题吗?
编辑:
现在我发现问题是 R CMD javareconf 没有改变 RStudio 的路径,从 RStudio 中的 rJava 安装日志来看:
checking Java support in R... present:
interpreter : '/usr/lib/jvm/default-java/bin/java'
archiver : '/usr/lib/jvm/default-java/bin/jar'
compiler : '/usr/lib/jvm/default-java/bin/javac'
header prep.: ''
cpp flags : '-I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux'
java libs : '-L/usr/lib/jvm/default-java/lib/server -ljvm'
checking whether Java run-time works... ./configure: line 3766: /usr/lib/jvm/default-java/bin/java: No such file or directory
no
configure: error: Java interpreter '/usr/lib/jvm/default-java/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/kzkedzierska/R/x86_64-pc-linux-gnu-library/3.5/rJava’
知道如何改变这些吗?相当于R CMD javareconf -e
在 Rstudio 中运行?