rJava installation fails on macOS 10.14

前端 未结 4 1807
天涯浪人
天涯浪人 2020-12-19 20:31

After upgrading to MacOS Mojave (10.14.1), I\'m no longer able to install rJava for R version 3.5.1 with Java version \"1.8.0_102\" installed.

I tried

相关标签:
4条回答
  • 2020-12-19 21:09

    I ran into same issue, when i was trying to install "rJava" in my macOs (Mojave version).

    Below steps i executed to resolve issue.

    R version : 3.6.1

    issue : configure: error: one or more Java tools are missing. *** JDK is incomplete! Please make sure you have a complete JDK. JRE is not sufficient.

    solution : execute below command in your terminal

    1. $ /usr/libexec/java_home -V
        Matching Java Virtual Machines (1):
            1.8.0_162, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk(your Java version)/Contents/Home
    
    1. $ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home

    2. $ export PATH=$JAVA_HOME/bin:$PATH

    3. $ R CMD javareconf

    4. $ R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")'

    0 讨论(0)
  • 2020-12-19 21:13

    After installing JDK 11.04 LTS I rain into the same error in R Studio on Mojave

    R was expecting Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk

    Despite running sudo R CMD javareconf the error still persisted

    Therefore I browsed to /Library/Java/JavaVirtualMachines/ in finder and renamed the folder "jdk-11.0.4.jdk" to "jdk-11.0.1.jdk"

    Restarted R and both library(rJava) and library(xlsx) now work.

    Hope this helps someone

    0 讨论(0)
  • 2020-12-19 21:17

    Posting the solution I found in case it helps others -- I don't quite understand why this work or if it's the right way so looking for better alternatives!

    This issue lead to this Apple forum where it's stated

    For legacy software that looks for the macOS headers in the base system under /usr/include, please install the package file located at: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14. pkg

    To do this, open terminal and run these commands

    cd /Library/Developer/CommandLineTools/Packages/
    open macOS_SDK_headers_for_macOS_10.14.pkg
    

    then follow prompts to install the package.

    After this, in the terminal, configure rJava and install as in the previous answer

    sudo R CMD javareconf

    R -e "install.packages('rJava')"

    and it should install without problem.

    0 讨论(0)
  • 2020-12-19 21:24

    I ran into the exact problem. I solved it by:

    1. Install the latest version of Java (dmg file)

    2. Install rJava in Studio: install.packages("rJava")

    3. In the terminal: sudo mv jdk-12.0.1.jdk jdk-11.0.1.jdk

    Otherwise the following error will appear in Rstudio:

    Error: package or namespace load failed for ‘rJava’:
     .onLoad failed in loadNamespace() for 'rJava', details:
      call: dyn.load(file, DLLpath = DLLpath, ...)
      error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
      dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
      Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
      Reason: image not found
    
    1. In Rstudio: library(rJava)

    2. rJava should have been loaded without issues.

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