0

I have read this post because I also have a Mac and nothing changed

rJava load error in RStudio/R after "upgrading" to OSX Yosemite

when I try to load xlsx library I get the following error

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

I cannot figure out what is wrong

library("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

does anyone know how to fix it?

nik
  • 2,500
  • 5
  • 21
  • 48
  • Some simple troubleshooting: xlsx seems unrelated except that it attempts to load rJava. You should try to load rJava directly and see if you get the same error. If so then we don't need to know about xlsx. – Dason Sep 17 '17 at 22:27
  • Urg, getting rJava right is hard (but useful). In my experience, it's one of those packages I _must_ build from source to get it to work. Getting it to build probably entails making sure your environment variables are set properly (`$PATH` and `$JAVA_HOME`), and `R CMD javareconf`ing. – alistaire Sep 17 '17 at 22:28
  • 1
    That said, if you're _only_ using rJava for xlsx, the simple answer is to use `readxl` and/or `openxlsx`, which don't require Java. – alistaire Sep 17 '17 at 22:29
  • Here's another useful stackoverflow post on rJava: https://stackoverflow.com/questions/27661325/unable-to-load-rjava-on-r But I agree with @alistaire that `readxl` is a far superior product just for its avoidance of `rJava`. – lebelinoz Sep 17 '17 at 22:50
  • @alistaire thanks, I will use the openxlsx then but it is making me crazy that I cannot figure it out – nik Sep 17 '17 at 22:54
  • @ lebelinoz that is for windows , not unix stuff but thanks I will go through it too – nik Sep 17 '17 at 22:55

0 Answers0