Home >Java >javaTutorial >Why Does rJava Fail to Load in RStudio After an OSX Yosemite Upgrade, and How Can I Fix It?

Why Does rJava Fail to Load in RStudio After an OSX Yosemite Upgrade, and How Can I Fix It?

DDD
DDDOriginal
2024-12-21 10:38:09874browse

Why Does rJava Fail to Load in RStudio After an OSX Yosemite Upgrade, and How Can I Fix It?

RStudio/R rJava Loading Error Post-OSX Yosemite Upgrade

Summary of the Issue

Following an upgrade to OSX Yosemite and R 3.2, loading rJava or its dependent packages triggers an error in RStudio. Opening R from the command line, however, resolves the issue.

Cause

The error stems from RStudio's incorrect Java path, resulting in the failure to locate the 'libjvm.dylib' library during the rJava loading process.

Attempted Fixes

Various fixes were attempted:

  • Adding JAVA_HOME and LD_LIBRARY_PATH configurations to .bash_profile
  • Reconfiguring Java using sudo R CMD javareconf -n
  • Setting 'java.home' using options("java.home")
  • Installing the latest Java Development Kit and reinstalling rJava from source
  • Installing Java for OS X 2014-001 (Java 6)

Solution

To resolve the issue, link 'libjvm.dylib' to '/usr/local/lib':

sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

This allows RStudio to locate 'libjvm.dylib' during rJava loading, thereby resolving the error.

The above is the detailed content of Why Does rJava Fail to Load in RStudio After an OSX Yosemite Upgrade, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn