R: rJava package install failing

后端 未结 17 1034
Happy的楠姐
Happy的楠姐 2020-11-22 16:28

When installing rJava using the install.packages(\"rJava\") command I get the following error:

checking Java support in R... present:
interprete         


        
相关标签:
17条回答
  • 2020-11-22 16:36

    Turns out my problem was an issue with my JAVA_HOME environment variable. Yes, shocking I know. My initial setting for PATH and JAVA_HOME looked like this:

    export JAVA_HOME=/usr/lib/jvm/java-6-sun
    export PATH=$PATH:$JAVA_HOME/bin
    

    And I added /jre so it now looks like this:

    export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
    export PATH=$PATH:$JAVA_HOME/bin
    

    Everything in Java seemed to work fine without the /jre but rJava would not. Odd.

    0 讨论(0)
  • 2020-11-22 16:41

    The problem was rJava wont install in RStudio (Version 1.0.136). The following worked for me (macOS Sierra version 10.12.6) (found here):

    Step-1: Download and install javaforosx.dmg from here

    Step-2: Next, run the command from inside RStudio:

    install.packages("rJava", type = 'source')
    
    0 讨论(0)
  • 2020-11-22 16:43

    On Arch Linux, I needed to install openjdk-src to get a JNI path working.

    In other words, these are the packages I needed to install before sudo R CMD javareconf ran successfully:

    local/jdk-openjdk 14.0.2.u12-1
        OpenJDK Java 14 development kit
    local/jre-openjdk 14.0.2.u12-1
        OpenJDK Java 14 full runtime environment
    local/jre-openjdk-headless 14.0.2.u12-1
        OpenJDK Java 14 headless runtime environment
    local/openjdk-src 14.0.2.u12-1
        OpenJDK Java 14 sources
    
    0 讨论(0)
  • 2020-11-22 16:45

    That is how I make it work :

    In Linux (Ubuntu 16.04)

    sudo apt-get install default-jre
    sudo apt-get install default-jdk
    sudo R CMD javareconf
    

    in R:

    install.packages("rJava")
    
    0 讨论(0)
  • 2020-11-22 16:45

    I was facing the same problem while using Windows 10. I have solved the problem using the following procedure

    1. Download Java from https://java.com/en/download/windows-64bit.jsp for 64-bit windows\Install it
    2. Download Java development kit from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html for 64-bit windows\Install it
    3. Then right click on “This PC” icon in desktop\Properties\Advanced system settings\Advanced\Environment Variables\Under System variables select Path\Click Edit\Click on New\Copy and paste paths “C:\Program Files\Java\jdk1.8.0_201\bin” and “C:\Program Files\Java\jre1.8.0_201\bin” (without quote) \OK\OK\OK

    Note: jdk1.8.0_201 and jre1.8.0_201 will be changed depending on the version of Java development kit and Java

    1. In Environment Variables window go to User variables for User\Click on New\Put Variable name as “JAVA_HOME” and Variable value as “C:\Program Files\Java\jdk1.8.0_201\bin”\Press OK

    To check the installation, open CMD\Type javac\Press Enter and Type java\press enter It will show

    In RStudio run

    Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jdk1.8.0_201")
    

    Note: jdk1.8.0_201 will be changed depending on the version of Java development kit

    Now you can install and load rJava package without any problem.

    0 讨论(0)
  • 2020-11-22 16:48

    below is one of my answers on another post - error: unable to load installed packages just now
    (this is also relevant to this question)

    For Linux(Ubuntu) users: If you have oracle-java (7/8) installed. It'll be at this location /usr/lib/jvm and sudo access is required.

    Create the file /etc/ld.so.conf.d/java.conf with the following entries:

    /usr/lib/jvm/java-8-oracle/jre/lib/amd64
    /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
    

    (Replace java-8-oracle with java-7-oracle depending on your java version)

    Then:

    sudo ldconfig
    

    Restart RStudio and then install the rJava package.

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