'File not found error when running Maxent in biomod2

When I run Maxent into biomod2 I got this error:

Error in file(file, "rt") : cannot open the connection

In addition: Warning messages:

1: running command 'java' had status 1 
2: In file(file, "rt") :
  cannot open file 'Sargassum.muticum.42.1.25.30/models/sstrange_sstmax_parmean_salinity/Sargassum.muticum.42.1.25.30_AllData_RUN1_MAXENT.Phillips_outputs/Sargassum.muticum.42.1.25.30_AllData_RUN1_Pred_swd.csv': No such file or directory

I've followed the steps of http://modata.ceoe.udel.edu/dev/dhaulsee/class_rcode/r_pkgmanuals/MAXENT4R_directions.pdf to add the java path and maxent.jar directory is copied in the working directory and no spaces are in the path.

When I type

file.exists("maxent.jar")

I get TRUE value.

These are my options:

model <- biomod2::BIOMOD_Modeling(formatdata                                   ,models=c("GLM","MAXENT.Phillips","RF","SRE")                                      ,models.eval.meth=c('KAPPA', 'TSS', 'ROC')                                      ,models.options = biomod_options('C:/Users/me/maxent.jar')                                      ,SaveObj = TRUE,do.full.models = FALSE                                      ,NbRunEval=1,DataSplitTable=dataSplitTable                                    ,VarImport=3,modeling.id = gsub("BO_", "", paste0(layers, collapse= "_")))


Solution 1:[1]

I had the same issue and the solution presented here solved my problem: Error running maxent from within biomod2 in R

In short, your path to the maxent.jar should not contain any spaces.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jemand-r