Error with installation of rJava LoadLibrary failure: %1 is not a valid Win32 application

82 views Asked by At

I tried to install rJava but got these errors. Please help.

install.packages("rJava") WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/Ersan/AppData/Local/R/win-library/4.2’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/rJava_1.0-6.zip' Content type 'application/zip' length 1245703 bytes (1.2 MB) downloaded 1.2 MB

package ‘rJava’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Users\Ersan\AppData\Local\Temp\RtmpULJHwE\downloaded_packages

library(rJava) Error: package or namespace load failed for ‘rJava’: .onLoad failed in loadNamespace() for 'rJava', details: call: inDL(x, as.logical(local), as.logical(now), ...) error: unable to load shared object 'C:/Users/Ersan/AppData/Local/R/win-library/4.2/rJava/libs/x64/rJava.dll': LoadLibrary failure: %1 is not a valid Win32 application.

Hello, my operating system is windows 11. I downloaded both 32-bit and 64-bit java after the error but nothing is changed. I need rJava to be able to use maxent in biomod2.

1

There are 1 answers

0
Esther On

What I have done in order to train Maxent models from the biomod2 package is:

  1. Load the package rJava firstly (i.e. library(rJava)).
  2. Download Maxent from the official website, unzip the file and move the folder to the desired path.
  3. Then, you will have to write the path to the Maxent software folder. To do this, when you set modeling options for training models, make sure to write the following code:
myBiomodOptions <- BIOMOD_ModelingOptions(
      MAXENT = list(
        path_to_maxent.jar = "C:/Users/USER/Downloads/maxent", # In this case, I have the Maxent folder in the downloads folder
        ... # Write here your settings
      )
    )

Do not forget to check the official biomod2 documentation.