-1

Reinstalled Java to get

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Ran:

sudo R CMD javareconf

Terminal recognized Java, seemed like everything worked

But then in rStudio:

library(rJava)

Received this error:

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

1 Answers1

0

I found that if you set your System Environment to look for the specific Java file, that most packages with Java works out pretty well. Note, this code is for 64bit Windows PC, you'll will have to figure it out for Unix/Linux.

# Set Java HOME for 64bit JRE: JAVA - https://java.com/en/download/manual.jsp
Sys.setenv("JAVA_HOME" = "C:\\Program Files\\Java\\jre1.8.0_131")

You will have to restart your machine/Rstudio after you set it up the first time. I have this run in a set up file when I load my most common libraries, but you may not have to do it every time.