> registerDoSNOW(makeCluster(4, type="SOCK")) Loading required package: methods Loading required package: DBI Loading required
> package: rJava 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.4/Resources/library/rJava/libs/rJava.so':
> dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so,
> 6): Library not loaded: @rpath/libjvm.dylib Referenced from:
> /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
> Reason: image not found Error: package ‘rJava’ could not be loaded
> Execution halted
This also happens if I try to use Knitr. So it is not related to registerDoSNOW() but to rJava and some kind of wrong pathing.
I've researched the common solutions (e.g., rJava load error in RStudio/R after "upgrading" to OSX Yosemite) to rJava not loading.
1) My Java is 64 bit version
2) library(rJava)
loads fine
3) It's only when I try to use registerDoSNOW(makeCluster(4, type="SOCK"))
This only started happening after I upgraded to R 3.4.2 from 3.3. I upgraded because data.table
complained that it could not make use of 64 bit architecture. When I upgraded, RStudio wouldn't run Java, which I fixed by executing sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
I tried the solutions here http://paulklemm.com/blog/2015-02-20-run-rjava-with-rstudio-under-osx-10-dot-10/ with no avail.
java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
I believe this process will solve your issue.
install rJava from within a r terminal
run ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
run R CMD javareconf
in a mac terminal session
Basically you're just setting up the java file that rJava needs and then reconfiguring R so it knows where to look.
If you get an error with something like /opt/X11/lib/* in it, then you need to install XQuartz, which can be found here.