Install rJava - "configure: error: one or more JNI types are different from the corresponding native type"

I encountered this problem when installing rJava on R3.0.1: "configure: error: one or more JNI types are different from the corresponding type"

A detailed message is given below. I searched for similar problems, but my problem is a little more complicated, and many of the proposed solutions either did not work, or I could not try, because I work on a server on which I do not have write access to the system libraries.

OS : Linux 2.6.18-348.6.1.el5 # 1 SMP Tue May 21 15:44:27 EDT 2013 x86_64 x86_64 x86_64 GNU / Linux (information given by entering "uname -a" sorry, I could not understand this information "

R : R3.0.1, I downloaded the source, placed it in my home directory and built R from the source.

rJava : I ran 'install.packages ("rJava")', during installation I got:

===========================
checking Java support in R ... is present:
interpreter: '/ usr / bin / java' Archiver: '/ usr / bin / jar' compiler: '/ usr / bin / javac' Header header prep .: '/ usr / bin / javah'
cpp flags: '-I / usr / lib / jvm / java-1.7.0-openjdk-1.7.0.9.x86_64 / jre /../ include -
I / USR / Library / JVM / Java-1.7.0-OpenJDK-1.7.0.9.x86_64 / JRE /../ include / Linux "
java libs: '-L / usr / lib / jvm / java-1.7.0-openjdk-1.7.0.9.x86_64 / jre / lib / amd64 / se
rver -ljvm 'Check for compilation of JNI programs ... yes Check for JNI data types ... configure: error: One or more JNI types are different from the corresponding native type. You may need to use custom compiler flags or
another compiler to fix this.
ERROR: configuration failure for package 'rJava'
* removal of '/home/me/R-3.0.1/library/rJava'

====================================

Since I can remotely access the server, I do not have write access to anything outside my home directory / home / me.

Any information would be highly appreciated!

+4
java r jni rjava
source share
3 answers

I ran into the same problem that tried to install.packages("rJava") in R version 3.0.2 if I tried to install it as a regular user (Linux, Debian). There was no problem running install.packages("rJava") as root. Then the library(rJava) attempt worked for root, but not for me as a user:

 Error : .onLoad failed in loadNamespace() for 'rJava', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/usr/usr.local.original.Debian/lib/R/site-library/rJava/libs/rJava.so': libjvm.so: cannot open shared object file: No such file or directory 

This problem requires adding JAVA_HOME and LD_LIBRARY_PATH environment LD_LIBRARY_PATH to ~/.login (the following instructions are found in Problem setting the Java environment path on Ubuntu (libjvm.so: cannot open shared objects file: there is no such file or directory) ):

 setenv JAVA_HOME /usr/lib/jvm/java-7-oracle/ setenv LD_LIBRARY_PATH $JAVA_HOME/jre/lib/amd64:$JAVA_HOME/jre/lib/amd64/server # For c-shell; for bash, it would have to be: export JAVA_HOME=/usr/lib/jvm/java-7-oracle/ export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64:$JAVA_HOME/jre/lib/amd64/server 

So, you will need to set the rJava system administrator for you, then set the environment variables and, of course, set your own .libPaths() in R, for example, find rJava.

+9
source share

I got the same issue on my mac OSx El Capitan. I tried updating java paths / envs used by R using "R CMD javareconf" with no effects.

Finally, I saw that when I ran "R CMD javareconf" my path to the Java library: the output was empty. Digging further, I realized that my JAVA_HOME is not installed correctly, as indicated here by fooobar.com/questions/46579 / .... I had to add an extra / jre to the JAVA_HOME path.

+5
source share

Using linux, in particular 64-bit Gentoo, my solution was to add the following line to /etc/env.d/20java-config

 LD_LIBRARY_PATH="/etc/java-config-2/current-system-vm/jre/lib/amd64:/etc/java-config-2/current-system-vm/jre/lib/amd64/server" 

Then

  • Run env-update
  • source / etc / profile
  • run rstudio (or if you use the GUI menu, log out and log in to boot the environment)

The above change should be done using root, but will then be applied to non-root users who use the same system the next time they log on.

Basically, the rJava conf test could not find libjvm.so, the conftest program will compile, but not the link :)

+1
source share

All Articles