Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The error of sudo R CMD javareconf

Tags:

java

r

sudo R CMD javareconf

Java interpreter : /usr/lib/jvm/default-java/jre/bin/java
Java version     : 1.8.0_121
Java home path   : /usr/lib/jvm/default-java
Java compiler    : not present
Java headers gen.: 
Java archive tool: 

trying to compile and link a JNI program 
detected JNI cpp flags    : 
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: 没有那个文件或目录
compilation terminated.
/usr/lib/R/etc/Makeconf:159: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program


JAVA_HOME        : /usr/lib/jvm/default-java
Java library path: 
JNI cpp flags    : 
JNI linker flags : 
Updating Java configuration in /usr/lib/R
Done.

When I run sudo R CMD javareconf,the result tells me that jni.h is not found. I install Java and Hadoop and I want to install R packages 'rJava'.But When I install 'rJava' and the Rstudio also run error.First, I want to know how to solve sudo R CMD javareconf and find the jni.h file.

like image 508
Rainbow Avatar asked Feb 04 '23 11:02

Rainbow


1 Answers

The compiler flags suggest you are on Debian or Ubuntu. You could then use what is use by the R package itself for its build:

sudo apt-get install default-jdk

The keys is "jdk" -- development kit, not just "jre" aka run-time environment.

But if you just want the rJava package, try

sudo apt-get install r-cran-rjava
like image 59
Dirk Eddelbuettel Avatar answered Feb 07 '23 08:02

Dirk Eddelbuettel