R mailr 包未加载 Java

R mailr package not loading Java

我正在 Ubuntu 20.04 机器上工作,试图 运行 一个发送带有 mailR 包的 pdf 的 R 脚本。我已经安装了 Oracle Java 和 运行“sudo R CMD javareconf”。这是输出

  meteo@BOIRA:~/PROJECTES/SANITAT/TREBALL$ sudo R CMD javareconf
*** JAVA_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/java
Java version     : 14.0.1
Java home path   : /usr/lib/jvm/java-14-oracle
Java compiler    : /usr/bin/javac
Java headers gen.:
Java archive tool: /usr/bin/jar

trying to compile and link a JNI program
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/lib/jvm/java-14-oracle/include -I/usr/lib/jvm/java-14-oracle/include/linux    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=. -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-14-oracle/lib/server -ljvm -L/usr/lib/R/lib -lR


JAVA_HOME        : /usr/lib/jvm/java-14-oracle
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /usr/lib/R
Done.

然后我安装了rJava,显然是成功的。但是当我尝试加载 mailr 包时,我得到这个错误:

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/meteo/R/x86_64-pc-linux-gnu-library/3.6/rJava/libs/rJava.so':
  libjvm.so: cannot open shared object file: No such file or directory

但是 rJava.so 存在于 /home/meteo/R/x86_64-pc-linux-gnu-library/3.6/rJava/libs/

如果我echo $JAVA_HOME它是空的。我认为 R 没有正确找到 java,但无法弄清楚如何将 R 指向实际的 java 安装,假设安装了 Java

meteo@BOIRA:~/PROJECTES/SANITAT/TREBALL$ java -version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

任何帮助将不胜感激,在此先感谢。

谷歌终于找到答案,希望对以后的人有所帮助

我需要在我的服务器 /home/meteo/R/x86_64-pc-linux-gnu-library/3.6/mailR/java

的 mailR java 目录中复制 javax.activation-api-1.2.0.jarjavax.activation-1.2.0.jar

现在一切正常。