无法在rstudio服务器中加载rJava库

时间:2018-09-20 20:01:57

标签: r rjava

我正在尝试在Rstudio服务器环境中使用rJava库。当我发出:

库(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 '/opt/microsoft/ropen/3.5.1/lib64/R/library/rJava/libs/rJava.so':
  libjvm.so: wrong ELF class: ELFCLASS32

我验证了Java和R发行版都是64位。

R.Version()
$system
[1] "x86_64, linux-gnu"

java -version:

Java HotSpot(TM) 64-Bit Server VM

我通过执行ls确实看到了文件:

ls -l /opt/microsoft/ropen/3.5.1/lib64/R/library/rJava/libs/rJava.so
-rwxr-xr-x 1 root root 365280 Sep 20 15:31 /opt/microsoft/ropen/3.5.1/lib64/R/library/rJava/libs/rJava.so

有什么想法吗?

我执行了@megatron用户推荐的

sudo R CMD javareconf

我收到此错误:

trying to compile and link a JNI program
detected JNI cpp flags    :
detected JNI linker flags :
gcc -std=gnu99 -I/opt/microsoft/ropen/3.5.1/lib64/R/include -DNDEBUG   -DU_STATIC_IMPLEMENTATION   -fpic  -DU_STATIC_IMPLEMENTATION -O2 -g  -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
 #include <jni.h>
                 ^
compilation terminated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program

1 个答案:

答案 0 :(得分:0)

尝试在命令行上运行以下命令:

sudo R CMD javareconf