R - Problems with JAVA (Linux Mint)

Asked

Viewed 258 times

2

I am trying to install the Getdfpdata() package but am getting this error:


checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : ''
java libs   : ''
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.

ERROR: configuration failed for package ‘rJava’
* removing ‘/home/rtheodoro/R/x86_64-pc-linux-gnu-library/3.6/rJava’

I use Linux Mint 19.2.

When I spin sudo R CMD javareconf at the terminal, I get:

*** JAVA_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/java
Java version     : 1.8.0_221
Java home path   : /usr/lib/jvm/java-ibm-x86_64-80/jre
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : 
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/compressedrefs -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: jni.h: Arquivo ou diretório inexistente
 #include <jni.h>
          ^~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:167: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program


JAVA_HOME        : /usr/lib/jvm/java-ibm-x86_64-80/jre
Java library path: 
JNI cpp flags    : 
JNI linker flags : 
Updating Java configuration in /usr/lib/R
Done.
$ javac -version
javac 1.8.0_222

In the /usr/lib/jvm folder, it has four folders: ibm-java80-jre-x86_64 , java-1.8.0-openjdk-amd64 , java-8-openjdk-amd64 , java-ibm-x86_64-80 . I don’t know why.

Has anyone ever been through this ? I’ve seen several answers to this problem, but none solved.

1 answer

3


Anyway, I solved ! With the response of "Please don’t Laugh at me" in https://stackoverflow.com/questions/42562160/r-cmd-javareconf-not-finding-jni-h

What I did:

(1) I have updated all repositories sudo apt update -y (2) I made sure that javajdk is installed sudo apt install -y openjdk-8-jdk openjdk-8-jre (3) Then, I pointed to R the java path, explicitly to JDK 8 sudo R CMD javareconf JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

I’m sorry I asked the question. I tried several other answers and it didn’t work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.