I am working in an Ubuntu 20.04 machine trying to run an R script that sends a pdf with mail
R package. I have installed Oracle Java and run "sudo R CMD javareconf
". This is the output
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.
Then I have installed rJava
, apparently successfull. But when I try to load mailr
package I get this error:
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
But rJava.so
exists in /home/meteo/R/x86_64-pc-linux-gnu-library/3.6/rJava/libs/
If I echo $JAVA_HOME
it is empty. I think R does not properly find java but can't figure out how to point R to actual java installation, assuming Java is installed
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)
Any help would be appreciated, thanks in advance.
Finally found the answer googleing, hope it helps someone in the future
I needed to copy javax.activation-api-1.2.0.jar
and javax.activation-1.2.0.jar
in the mailR java directory in my server /home/meteo/R/x86_64-pc-linux-gnu-library/3.6/mailR/java
Now it is working fine.