.jinit() : Cannot create Java virtual machine When using maxent() function.

2,560 views
Skip to first unread message

ahwangyuwei

unread,
Nov 13, 2011, 9:29:52 PM11/13/11
to Maxent
Dear all,
when using .jinit() I get the message .jinit() : Cannot create
Java
virtual machine (-1).
The details:
I am using the Dismo package.Dismo has a function 'maxent' that
communi-cates with this program(MaxEnt).MaxEnt is available as a stand-
alone Java program.
It is normal when I execute the command : "jar <-
paste(system.file(package="dismo"), "/java/maxent.jar", sep='')" when
I execute the function: xm <- maxent(predictors, pres_train,
factors='biome').The R show the error(Cannot create Java virtual
machine) . Java is correct installed .
My R version is 2.14.0.
I don't know how to solve the problem. Will you help me out?
Thank you,all.
Yuwei Wang

John B

unread,
Nov 14, 2011, 4:46:27 PM11/14/11
to max...@googlegroups.com
Hi Wang,

I haven't looked at the info that Robert pointed you to (https://r-forge.r-project.org/forum/message.php?msg_id=5182&group_id=623), but have seen elsewhere that this can be caused by insufficient RAM available to Java. When you get the error in R, are you able to open the Maxent gui, or does that fail as well?

If R is hanging onto your memory, you could try a gc() now and again, which can free up memory.

Other than that, I would try and chase up rJava support.

Good luck,
John

ahwangyuwei

unread,
Nov 14, 2011, 7:45:45 PM11/14/11
to maxent
Hi,
  My maxent GUI is running normally.But in R, I always get the error message.
                                             Wang
 
 
2011-11-15

ahwangyuwei

发件人: John B
发送时间: 2011-11-15  05:46:27
收件人: maxent
抄送:
主题: .jinit() : Cannot create Java virtual machine When using maxent()function.
-- 
You received this message because you are subscribed to the Google Groups "Maxent" group.
To view this discussion on the web visit https://groups.google.com/d/msg/maxent/-/6aZp3LUyaYIJ.
To post to this group, send email to max...@googlegroups.com.
To unsubscribe from this group, send email to maxent+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/maxent?hl=en.

John B

unread,
Nov 14, 2011, 8:48:18 PM11/14/11
to max...@googlegroups.com
Are you using Linux?

ahwangyuwei

unread,
Nov 14, 2011, 9:49:18 PM11/14/11
to maxent
I am using WinXp.
 
 
2011-11-15

ahwangyuwei

发件人: John B
发送时间: 2011-11-15  09:48:18
收件人: maxent
抄送:
主题: Re: .jinit() : Cannot create Java virtual machine When usingmaxent()function.
Are you using Linux?

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To view this discussion on the web visit https://groups.google.com/d/msg/maxent/-/KhMMbbGWp3oJ.

John B

unread,
Nov 14, 2011, 10:11:28 PM11/14/11
to max...@googlegroups.com
Hmm, sorry I probably don't have the answer for you... but it could be worth removing and reinstalling rJava. Good luck.

John

David Galbraith

unread,
Nov 15, 2011, 9:58:14 AM11/15/11
to max...@googlegroups.com
I'm perplexed by these issues too, but so far have not thrown caution to the wind and installed a Linux-based OS.

I have given up on using Dismo to call R via Java stuff, but still use a bit of R-Dismo for running GBM/BRT things and playing around with Maxent outputs.  A great way to get reliable outputs from Maxent is to customize a command line statement similar to the one that's in all the documentation for Maxent.  Then, as long as we're allowed to keep accessing the old Dossy type of command line shell, stuff should keep working for now maybe.

That said, let's hope windows 8 does not come out tomorrow and interfere with work flows.

Dave

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To view this discussion on the web visit https://groups.google.com/d/msg/maxent/-/6aZp3LUyaYIJ.

ahwangyuwei

unread,
Nov 15, 2011, 7:59:42 PM11/15/11
to maxent
Thank you,David.
You siad "A great way to get reliable outputs from Maxent is to customize a command line statement similar to the one that's in all the documentation for Maxent."
I am a beginner for this. I want to ask you that How to do?
Can you give me some references?
Thanks again.
                                        Wang
 
2011-11-16

ahwangyuwei

sender: David Galbraith
time: 2011-11-15  22:58:14
receiver: maxent
cc:
subject: Re: .jinit() : Cannot create Java virtual machine When using maxent() function.
I'm perplexed by these issues too, but so far have not thrown caution to the wind and installed a Linux-based OS.

I have given up on using Dismo to call R via Java stuff, but still use a bit of R-Dismo for running GBM/BRT things and playing around with Maxent outputs.  A great way to get reliable outputs from Maxent is to customize a command line statement similar to the one that's in all the documentation for Maxent.  Then, as long as we're allowed to keep accessing the old Dossy type of command line shell, stuff should keep working for now maybe.

That said, let's hope windows 8 does not come out tomorrow and interfere with work flows.

Dave

On Mon, Nov 14, 2011 at 4:46 PM, John B <j.baum...@pgrad.unimelb.edu.au> wrote:
--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To view this discussion on the web visit https://groups.google.com/d/msg/maxent/-/6aZp3LUyaYIJ.
To post to this group, send email to max...@googlegroups.com.
To unsubscribe from this group, send email to maxent+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/maxent?hl=en.

David Galbraith

unread,
Nov 16, 2011, 9:16:50 AM11/16/11
to max...@googlegroups.com
Rock on, below my signature is the part of the Help file that I adapted for the project I'm working on right now.  I'll also attach a Word version of the Help file, because it pretty much works to explain Maxent's functionality, limitations, and implementation procedures.  There is also an enormous amount of peer-reviewed primary literature that describes the use of Maxent for a diverse variety of project-specific goals, but I'm pretty sure that you've already stumbled through part of that quagmire, and are interested in experimenting with the software for your own purposes.  Good luck, and have fun?

Dave

Batch mode

All parts of the interface can be set from the command line, and the Run button can be automatically pressed after startup.  This allows for the program to be invoked in batch mode, multiple times in sequence, if required.  The command line flags can also be added to the maxent.bat file, at the end of the "java ..." line, to change the default settings of the program. Some of the more common flags have abbreviations that can be used instead of the full flag. As an example, the following two invocations are equivalent:

java -mx512m -jar maxent.jar environmentallayers=layers samplesfile=samples\bradypus.csv outputdirectory=outputs togglelayertype=ecoreg redoifexists autorun

java -mx512m -jar maxent.jar -e layers -s samples\bradypus.csv -o outputs -t ecoreg -r -a

Any boolean flag can be given the prefix "no" or "dont" to turn the flag off. Abbreviations for boolean flags toggle the default value. The available flags are, in no particular order:

MaxEnt_help.docx

Elena Moreno

unread,
Feb 21, 2013, 10:55:31 AM2/21/13
to max...@googlegroups.com, ahwan...@sina.com
Hi all!

I am running Maxent in R and I am finding the same problem:

error en R: .jinit() : Cannot create Java virtual machine (-4)

has anyone solved it???

P.D. I have tried uninstalling and reinstalling Java and still it doesn't work....


Thanks a lot!
Elena

Izzy

unread,
Jul 10, 2013, 8:27:59 PM7/10/13
to max...@googlegroups.com, ahwan...@sina.com
Hi Elena, 
I have tried using the command:
options( java.parameters = "-Xmx1g" )

as suggested by the dismo pacakge to increase the access to RAM but this then leads to a new error:

"Error in .jinit() : Cannot create Java virtual machine (-1)"

has anyone resolved this issue? Any advice would help. 

Cheers
Israel 

Agus Camacho

unread,
Jan 11, 2016, 3:39:13 PM1/11/16
to Maxent, ahwan...@sina.com
The error that appears to me is:

Error in .jinit() : Unable to create a Java class loader.


R version 3.2.1 (2015-06-18)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
 [1] foreign_0.8-63     plyr_1.8.3         maptools_0.8-36    geosphere_1.4-3    rgdal_1.0-7       
 [6] rJava_0.9-7        outliers_0.14      XML_3.98-1.3       PBSmapping_2.69.76 rgeos_0.3-12      
[11] reshape_0.8.5      dismo_1.0-12       raster_2.4-15      sp_1.1-1          

loaded via a namespace (and not attached):
[1] Rcpp_0.12.0     lattice_0.20-31 grid_3.2.1      tools_3.2.1
Reply all
Reply to author
Forward
0 new messages