install rJava - “configure: error: One or more JNI types differ from the corresponding native type”

后端 未结 3 669
轮回少年
轮回少年 2021-01-05 14:01

I have came across this problem while installing rJava on R3.0.1: \"configure: error: One or more JNI types differ from the corresponding native type\"

The detailed

相关标签:
3条回答
  • 2021-01-05 14:32

    Using linux, specifically, 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
    • start rstudio (or if you are using GUI menu, logout and login to load the environment)

    The above change needs to be made by root but then will apply to non-root users who use the same system, on next login.

    Basically, rJava conf test was failing to find libjvm.so, the conftest program would compile but not link :)

    0 讨论(0)
  • 2021-01-05 14:34

    I ran into the same problem trying to install.packages("rJava") in R version 3.0.2, as long as I tried to install as ordinary user (Linux, Debian). There was no problem running install.packages("rJava") as root. Then, trying library(rJava) 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 required to add the environment variables JAVA_HOME and LD_LIBRARY_PATH to ~/.login (following instructions found at Trouble in Setting Java Environment Path on Ubuntu (libjvm.so: cannot open shared object file: 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 would have to have a system administrator install rJava for you, then set your environment variables and, of course, set your own .libPaths() in R such as to find rJava.

    0 讨论(0)
  • 2021-01-05 14:34

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

    Finally, I saw that when I ran "R CMD javareconf" my Java library path: in the output was empty. By digging up further I figured out that my JAVA_HOME was not set correctly as pointed here https://stackoverflow.com/a/3311983 . I had to add an extra /jre in the JAVA_HOME path.

    0 讨论(0)
提交回复
热议问题