Have you ever received a "JVM Terminated. Exit code=-1" message when starting an Eclipse application?
Unfortunately this message doesn't tell you much about what caused the Java process to exit. Hopefully some of the information below will help you to troubleshoot and solve this problem.
Solving the Problem?
There are a few methods to get more information from the failure and troubleshoot the cause of the problem, but it's actually worth trying a common solution to this problem first: reducing the Java heap size.
In order to reduce the Java heap size, you need to add the "-vmargs -Xmx512M" options to Eclipse, which can either be done on the command line or by modifying the .ini file in the same directory as the Eclipse executable. Once this is done, Eclipse should hopefully start successfully and the problem is solved.
If you'd like more information on what the maximum Java heap that will run on Windows is, John Pape has an excellent blog post here
If this doesn't solve the problem, then we have some troubleshooting to do.
Troubleshooting the Problem
The reason for trying the solution of reducing the Java heap size first is that it's a problem that is very hard to debug under Eclipse. The IBM JVM does produce some useful messages if the heap size is too large:
C:\>java -Xmx2G -versionHowever as Eclipse is still starting the JVMs error message can't be logged to the Eclipse error log in workspace/.metadata/.log, and if Eclipse isn't being run from the MS DOS prompt or console, the message is lost.
JVMJ9VM015W Initialization error for library j9gc24(2): Failed to instantiate heap; 2G requested
Could not create the Java virtual machine.
Also, because allocating the Java heap is one of the first actions the JVM takes during startup, a number of the JVMs troubleshooting capabilities are not yet enabled either. So ff reducing the Java heap size has not solved the problem, then the JVMs troubleshooting capabilities should be available to us to do further debugging.
Obtaining more information an the "JVM Terminated. Exit code=-1" Event
The IBM JVMs offer several mechanisms for getting more data from this event. In this case the best option would be to request the generate a Javadump file (javacore.txt) when the Java process exits. This can be done by adding the following command line argument to the Java, again using the -vmargs option to Eclipse or the .ini file:
-Xdump:java:events=vmstopThis requests a dump of type "java" (a javacore.txt file) on an event of "vmstop" (JVM shutdown). It's also possible to specify additional options to specify which exit code to produce dumps on, and where to write the javacore.txt file:
-Xdump:java:events=vmstop,filter=#-1 only produce a javacore.txt file if the exit code is -1When specifying the file option, there are a number of substitutions that you can add into the file name. By default the file name is:
-Xdump:java:events=vmstop,filter=#-1,file=c:\javacore.txt write the file as c:\javacore.txt.
javacore.%Y%m%d.%H%M%S.%pid.%seq.txtwhere the substitutions are for year, month, day, hours, minutes, seconds, process id, and sequence.
This should cause a javacore.txt file to be generated when the exit code -1 is received. The javacore.txt gives you a whole host of information about the state of the Java process, including the command line arguments and the stack traces of all the running threads.
Looking for the "Current Thread Details" section will give you the stack trace for the thread that exited, and this should give you an idea of why the JVM shut down.