Pages Navigation Menu

Coding is much easier than you think

Solution for “Could not create the Java Virtual Machine” issue

Posted by on Nov 26, 2013 in Eclipse, Java | 2 comments

If you get the below error message while executing java program

Error:Could not create the Java Virtual Machine.
Error:A fatal exception has occurres.Program will exit.


To resolve this issue, following steps are needed to be followed (on Windows XP, Windows 7, Windows 8):

  • Right Click on My Computer Icon and click on Properties
  • Click on Advanced Systems Settings
  • Then Environment Variables
  • Under System Variables, click New
  • In which give Variable Name as: _JAVA_OPTIONS
  • Variable Value: -Xmx1024m
  • Click OK

That’s it, now your Java program should execute properly.

Heap size allocated by the JVM by default can be Increased/Modified by using Java -Xmx/s command line options.

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size


Click here to know about getting JVM heap size, used memory, total memory using Java Runtime programatically.

Read More