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

Why Does rJava Fail to Load After Upgrading to OSX Yosemite, and How Can I Fix It?

DDD
DDDOriginal
2024-12-13 06:15:12290browse

Why Does rJava Fail to Load After Upgrading to OSX Yosemite, and How Can I Fix It?

rJava Loading Error After "Upgrading" to OSX Yosemite

Many users have encountered problems loading rJava after "upgrading" from OSX Mountain Lion to Yosemite. To resolve this issue, follow these steps:

  1. Ensure that Java 6 is installed.
  2. Reconfigure Java using: sudo R CMD javareconf -n
  3. Set options("java.home").
  4. Install the latest Java Development Kit and reinstall rJava from source.

Despite these steps, you may encounter the following error:

Error : .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.2/Resources/library/rJava/libs/rJava.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so
  Reason: image not found
Error: package or namespace load failed for ‘rJava’

To resolve this issue:

  1. Open RStudio using the following command: LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio
  2. Link libjvm.dylib to /usr/local/lib using: sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

This should allow you to load rJava and packages that depend on it without any errors.

The above is the detailed content of Why Does rJava Fail to Load After Upgrading to OSX Yosemite, 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