R CMD javareconf not finding jni.h R CMD javareconf not finding jni.h r r

R CMD javareconf not finding jni.h


I'm not sure if an answer has been confirmed here, but I would point everyone to this article by Andrew Collier.

What he recommends:

(1) Updating all repositories

sudo apt update -y

(2) Being sure JRE and JDK 8 are installed

sudo apt install -y openjdk-8-jdk openjdk-8-jre

(3) Then, as many users have said already, pointing R to java with an explicit path to JDK 8

sudo R CMD javareconf JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

The specific Java package does not matter too much as long as it has all the necessary compiled contents within the /include directory.

user@laptop:~$ ls /usr/lib/jvm/java-8-openjdk-amd64/include/classfile_constants.h  jdwpTransport.h  jvmticmlr.h  linuxjawt.h                 jni.h            jvmti.h

For more on this, I would recommend how to make jni.h be found? for going about locating/compiling this directory correctly.


R is looking at different location:

detected JNI cpp flags    : -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux

I experienced similar problem, but everything is fine after installing jdk:

sudo apt-get install openjdk-8-jdk


Had the same issue. Fixed by specifying the path to the Java folder. Briefly, after installing Java you may get a line like this.

update-alternatives: using /usr/lib/jvm/java-9-openjdk-amd64/bin/jar to provide /usr/bin/jar (jar) in auto mode

I specified that path as JAVA_HOME argument when calling javareconf, as follows.

sudo R CMD javareconf JAVA_HOME=/usr/lib/jvm/java-9-openjdk-amd64/bin/jar

Hope this is useful