Fix Error: Could not create the Java Virtual Machine on Windows - gHacks Tech News

Fix Error: Could not create the Java Virtual Machine on Windows

This tutorial explains how you can fix Java virtual machine creation errors on Windows.

Every now and then I like to play a relaxing computer game, and the excellent strategy game TripleA was my game of choice yesterday. It is a Java-based game but since the machine I wanted to run it on had Java (only untied from the browser) , I did not think that this would be an issue.

When I tried to start the game though after installation it quit immediately afterwards. The error message that it displayed was definitely Java related:

Error: Could not create the Java Virtual Machine

Error: A fatal exception has occurred. Program will exit.

First thing I did was double-check to make sure that Java was indeed properly installed - it was. It was the most recent version and the game should just run fine using it according to the game's website.

error could not create java virtual machine

After some digging around and testing I came up with a solution for the issue that worked and resolved the error message so that the Java application started just fine. It involves changing how much memory Java is allowed to use on the system.

Java on Windows uses an initial size of 16 Megabyte and a maximum of 64 Megabyte.  You can find that out by yourself by running the command java -XX:+PrintFlagsFinal -version  on your machine. Check the InitialHeapSize and MaxHeapSize values here (displayed in Bytes).

Now, to resolve the error message we need to increase the size that Java can use for memory. Here is how that is done (demonstrated using Windows 7, may differ slightly on other versions of Windows):

  1. Tap on Windows-Pause to open the System Control Panel applet. You can alternatively open the control panel manual to go there if you prefer it that way.
  2. Click on advanced system settings on the left.
  3. Select environmental variables here.
  4. Click on new under System Variables.
  5. Enter _JAVA_OPTIONS as the variable name.
  6. Enter -Xmx256M as the variable value.
  7. Click ok twice.

The setting is available right away, you do not need to restart the computer first. It raises the allowed memory to 256 Megabyte.  If your application does not run fine afterwards, try raising the memory to 512 or even 1024 Megabyte instead.

Note that this increases the maximum heap size only. If you also need to increase the minimum heap size, use -Xms256M for that.

Summary
Fix Error: Could not create the Java Virtual Machine on Windows
Article Name
Fix Error: Could not create the Java Virtual Machine on Windows
Description
How to fix the Java Error could not create the Java Virtual Machine after you run a Java program on your Windows PC.
Author

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.

If you like our content, and would like to help, please consider making a contribution:

Comments

  1. dutscher said on May 27, 2014 at 9:29 pm
    Reply

    thanks very much!

    1. jack said on September 19, 2015 at 1:01 pm
      Reply

      mine does not work

      1. Sravya said on February 23, 2016 at 11:09 am
        Reply

        Even mine doesn’t work :(

      2. arun said on September 7, 2016 at 2:19 am
        Reply

        Doent work

      3. Redd said on February 20, 2017 at 3:52 pm
        Reply

        yeah mine dont work either

  2. dgwarez said on June 5, 2014 at 9:45 am
    Reply

    Thanks. It worked for me!

  3. Ben T said on June 9, 2014 at 3:10 am
    Reply

    Thanks! You save my day

  4. Shelton said on October 28, 2014 at 11:59 pm
    Reply

    Brilliant! Thank you very much!

  5. duzgass said on November 11, 2014 at 5:23 pm
    Reply

    nice job, it solved a lot problems for me!

  6. Anonymous said on January 2, 2015 at 5:45 pm
    Reply

    It is not working me, I still get an error ‘Could not create Java Virtual machine’

    Any further thoughts on this?

    1. Anonymous said on March 30, 2015 at 3:58 am
      Reply

      Increased it to 1024M and it is not working, trying to run a patch for Skyrim

  7. Sridhar said on January 2, 2015 at 5:47 pm
    Reply

    It was not worked for me. Still getting same error after increasing heapsize to 512 as well.

    Could not create the Java virtual machine

    Any further solution to fix this?

  8. Harisha Pattela said on February 16, 2015 at 11:02 am
    Reply

    Thank you very much,the fix you have provided worked for me.

  9. Prathap Singh said on August 28, 2015 at 8:25 pm
    Reply

    Wow.. Very Useful Method.. It is working.. Thank You Very Very much….

  10. Med said on September 11, 2015 at 1:58 pm
    Reply

    muchas graaaacias

  11. Dmitri said on December 11, 2015 at 7:33 pm
    Reply

    Thanks a lot! It works!
    Spasibo ogromnoe! Rabotaet!

  12. Anonymous said on August 10, 2016 at 5:31 pm
    Reply

    thank you

  13. Anonymous said on October 21, 2016 at 1:20 am
    Reply

    I get :

    java.lang.IndexOutOfBoundsException: Index: 14, Size: 14
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at com.datanomic.director.eventlogger.client.EventLogController.updateColumns(EventLogController.java:502)
    at com.datanomic.director.eventlogger.client.EventLogController.initUI(EventLogController.java:361)
    at com.datanomic.director.eventlogger.client.EventLogController.access$700(EventLogController.java:99)
    at com.datanomic.director.eventlogger.client.EventLogController$1.finished(EventLogController.java:207)
    at com.datanomic.director.guihelper.SwingChore$1.run(SwingChore.java:90)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at com.datanomic.utils.blueprints.ui.chores.ChoreMaster$InvokeQueue$Invoker.run(ChoreMaster.java:600)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

  14. Reece said on December 20, 2016 at 2:52 am
    Reply

    Ive tried this and I have had no success but i am with windows 10

    1. Redd said on February 20, 2017 at 3:53 pm
      Reply

      same i think this thing is broken
      so um yeah no way of fixing java fo windows 10

  15. Ajay said on March 15, 2017 at 8:09 am
    Reply

    its not working for me after i add java_options in envt varibale path

    1. Anonymous said on December 4, 2017 at 11:26 am
      Reply

      yes….its not working

  16. stefan3112 said on March 19, 2017 at 2:16 pm
    Reply

    WORKS.Thanks.<3

  17. hamza said on May 11, 2017 at 6:52 pm
    Reply

    thank you so much

  18. Anonymous said on August 13, 2017 at 7:55 pm
    Reply

    its worked for me..thank u

  19. MrLexx000 said on September 8, 2017 at 1:35 pm
    Reply

    Hey Guys try this
    1.uninstall java
    2.restart your computer
    3.install the newest update of java!

  20. naveen said on September 18, 2017 at 9:14 am
    Reply

    yes its works for me…

  21. FishrOSE said on October 24, 2017 at 1:03 am
    Reply

    Excelente! :)

Leave a Reply