4

So I am trying to run the

library(ggplot2)
library(qdap)

but this error keeps coming up:

Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Error: package or namespace load failed for ‘qdap’:
 .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
In addition: Warning message:
running command '/usr/libexec/java_home' had status 1 

I am using R in Rstudio on a mac, and I've trawled through quite a few similar questions but none seem to work. I am quite new to using R and any help would be great thanks.

I tried using

install.packages("openNLPdata")

and this showed up which I think is a good thing

trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/openNLPdata_1.5.3-4.tgz'
Content type 'application/x-gzip' length 7323402 bytes (7.0 MB)
==================================================
downloaded 7.0 MB


    The downloaded binary packages are in
        /var/folders/h5/_5bjqp9j0g5gqr1794sw1xwh0000gn/T//RtmpaknsV6/downloaded_packages

But the error still occurs.

Thanks in advance

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • The message says rJava is not installed. But it may even be more fundamental in that the Java runtime may not be configured properly. There are additional steps beyond installing rJava. Read this set of answers: https://stackoverflow.com/questions/13610293/how-to-get-rjava-0-9-3-to-work-on-os-x-10-7-4-with-oracle-java-1-7 as well as searching SO on `[r] [osx] rjava install`. You should edit your question to include version number of the Java runtime that you have. – IRTFM Apr 13 '18 at 16:44
  • yeah trying {install.packages('rJava')} then {library(rjava)} produced the same error. And I believe my java runtime is upto date, the rjava is version 0.9-9 – chocolatekeyboard Apr 14 '18 at 09:10
  • You need to examine the system environment variables. You need the Java Dev-Kit. You can look at the java_home env-var from R with: `system('/usr/libexec/java_home')` and on my machine I get `/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home`. It's possible to have different environment variables in an R session than you would see just using a bash console window (i.e what you see with Terminal.app.) – IRTFM Apr 14 '18 at 15:51
  • @42 Thanks for responding. I managed to get `system('/usr/libexec/java_home')` to say the same as yours, but i really don't know what to do next, the other commands in the thread you linked don't seem to work either :S – chocolatekeyboard Apr 14 '18 at 18:05
  • I am still stuck at El Cap, so this SO Q&A may be relevant if you have a newer machine: "Installed rJava, Installed Java 8 update. Still cannot load rJava on MacOS Sierra" https://stackoverflow.com/questions/47083606/installed-rjava-installed-java-8-update-still-cannot-load-rjava-on-macos-sierr – IRTFM Apr 14 '18 at 22:14

1 Answers1

1

It seems like that package might need rJava to run, which may not be loaded in your environment. Try:

install.packages('rJava')
library('rJava')
Peter_Evan
  • 947
  • 10
  • 17
  • 2
    Thanks, trying that gives a similar error too `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: imag` – chocolatekeyboard Apr 14 '18 at 18:45