0

Ive been struggling with overcomming a series of errors for using the function maxent in the dismo package.

Loading required package: rJava Unable to find any JVMs matching version "(null)". No Java runtime present, try --request to install. 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 In addition: Warning message: running command '/usr/libexec/java_home' had status 1

Ive tried: 1- updating my R version 2- removing and reinstalling the latest Java version 3- removing and reinstalling rJava 4- Installing JGR

None have solved the issue. Any help out there?

I Del Toro
  • 913
  • 4
  • 15
  • 36
  • Do you have to set environment variables such as JAVA_HOME or JDK_HOME or JRE_HOME in order for rJava to find the Java stuff? Just guessing; I haven't used rJava. – Robert Dodier Jun 28 '17 at 21:47

2 Answers2

1

At the Terminal console execute:

machine-name:~ username$ which java
/usr/bin/java
machine-:~ username$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Since I have the jre installed I can go into R and run:

> library(rJava)
> help(pac=rJava)
> res <- .jinit(classpath="myClasses.jar", parameters="-Xmx512m")
> res
[1] 0    # the sign of a successful initiation

You should be displaying similar information as below:

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel  stats4    grDevices utils     datasets  graphics  stats    
[8] methods   base     

other attached packages:
 [1] rJava_0.9-8         MASS_7.3-47         copula_0.999-16   
  snipped the rest of my loaded package listing

I never had any success working with JGR so cannot help on that aspect.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
0

I had the same problem... to me, this worked:

  • Uninstall your java and install again, but make sure to install the 64bit version.
  • Then, install the packages

    install.packages("rJava"); install.packages("dismo")

  • here: http://biodiversityinformatics.amnh.org/open_source/maxent/ you download maxent... then paste the "maxent.jar" file in the 'java' folder of the 'dismo' package. You have to do this before loading the libraries. You find the directory of yor 'dismo' package running the following:

    system.file("java", package="dismo")

  • In your system, open the regedit.You will have to create a Prefs key in the JavaSoft folder. In mine, it's here: Computador\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft ... Depending on your system, it may be here: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft ...so, take a look, and asure yourself to create Prefs in the right directory. Then:

  • Right button click in JavaSoft > New > Key > name the key as Prefs. it is supposed to work now. Load the libraries and try it.

Thai
  • 493
  • 5
  • 15