我正在尝试在Anaconda基于debian(jessie)的docker容器中安装rJava。
作为根,我做了
$ apt-get update && apt-get install -y --no-install-recommends \
default-jdk default-jre libicu-dev
然后
$ R CMD javareconf
Java interpreter : /usr/lib/jvm/jdk1.8.0_121/jre/bin/java
Java version : 1.8.0_121
Java home path : /usr/lib/jvm/jdk1.8.0_121
Java compiler : /usr/lib/jvm/jdk1.8.0_121/bin/javac
Java headers gen.: /usr/lib/jvm/jdk1.8.0_121/bin/javah
Java archive tool: /usr/lib/jvm/jdk1.8.0_121/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/opt/conda/lib/R/include -DNDEBUG -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux -I/opt/conda/include -fpic -I/opt/conda/include -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
/opt/conda/lib/R/etc/Makeconf:133: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program
JAVA_HOME : /usr/lib/jvm/jdk1.8.0_121
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /opt/conda/lib/R
Done.
但是jni.h在JDK中是正确的:
# find /usr/lib/jvm/jdk1.8.0_121/ -name jni.h
/usr/lib/jvm/jdk1.8.0_121/include/jni.h
看起来
javareconf
似乎找不到它。而且,如果我查看可以使用javareconf设置的所有变量(例如JAVA_HOME),则看不到设置JNI cpp标志的能力,而这需要正确的包含。我已经在互联网上看到various posts这个问题,但没有解决方案。
最佳答案
R在不同的位置看:
detected JNI cpp flags : -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux
我遇到了类似的问题,但安装jdk后一切正常:
sudo apt-get install openjdk-8-jdk
关于java - R CMD javareconf找不到jni.h,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42562160/