Pages Navigation Menu

Coding is much easier than you think

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

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

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.

About Mohaideen Jamil

Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

  • Bram

    I tried this, still not working.

    I;m running windows 8 x64, installed Java x64.

    Tried for hours now, deinstalled it, removed all remaining folders of Java 6 and x84 version.

    Any suggestions?


    • Wayne Venn

      For 64bit OS I have seen heap size of 2048 recommended. That’s what I use.