rJava fails loading in RStudio on MacOS

See the error below, that I get in RStudio 0.98.472 and R 3.0.2.

> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/usr/local/Cellar/r/3.0.2/R.framework/Versions/3.0/Resources/library/rJava/libs/rJava.so':
dlopen(/usr/local/Cellar/r/3.0.2/R.framework/Versions/3.0/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib
Referenced from: /usr/local/Cellar/r/3.0.2/R.framework/Versions/3.0/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error: package or namespace load failed for ‘rJava’

Interestingly I do *not* get an error if I run the same in R in a simple console window.

The problem and a workaround are also described here: http://support.rstudio.org/help/discussions/problems/6939-rjava-fails-to-load-in-rstudio-desktop-os-x, but I wondered if the Talk Stats community found a better solution, or we just need to wait for the RStudio team to come out with a solution of their own.


Last edited: