简体   繁体   中英

unable to compile JNI program rJava

I want to install rJava but it doesnt work. When I am typing R CMD javareconf in the console I get the following error:

trying to compile and link a JNI progam
detected JNI cpp flags    :
detected JNI linker flags :
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -O3 -pipe  -g 
-c conftest.c -o conftest.o
conftest.c:1:17: error: jni.h: No such file or directory
conftest.c: In function 'main':
conftest.c:4: warning: implicit declaration of function 'JNI_CreateJavaVM'
make: *** [conftest.o] Error 1
Unable to compile a JNI program


Java library path:
JNI cpp flags    :
JNI linker flags :
Updating Java configuration in /usr/lib64/R
Done.

Any ideas how to fix it?

I know this is closed but I'm adding my solution for completeness. In effect I had the same problem and all was correctly installed. I had also run the

sudo R CMD javareconf

for system wide setting. What I needed was for it to work for my user. And in this case you should run

R CMD javareconf -e

without sudo and with appended -e.

Worked for me. :)

The jni.h file is part of JDK installation. You probably don't have Java JDK installed correctly. Download Oracle Java from here , or use your package manager.

If you have Java JDK already installed, set JAVA_HOME environment variable to point to the JDK directory.

I was also facing same error which was on RHEL8.1 & i resolved it as follows:

 yum --enablerepo=* install java-1.8* 

later i ran same command which was giving me error logs of R server.

 R CMD javareconf

which turns into the following output & succeed.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM