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

Martin Brinkmann
May 22, 2014
Tutorials
|
64

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
Advertisement

Previous Post: «
Next Post: «

Comments

  1. Resuidal rose said on July 13, 2021 at 7:17 pm
    Reply

    delete and install mc launcher

  2. mohanraj said on June 7, 2021 at 7:38 pm
    Reply

    worked for me thanks a lot

  3. Anonymous said on June 1, 2021 at 1:39 pm
    Reply

    cant get it to work

  4. Anonymous said on December 6, 2020 at 3:42 pm
    Reply

    Thanks this worked

  5. guest said on November 19, 2020 at 9:08 pm
    Reply

    doesn’t work

  6. CeceliA said on November 3, 2020 at 7:27 pm
    Reply

    this still didnt work

  7. AKO338 said on August 29, 2020 at 3:34 pm
    Reply

    wow man it work!!!! for real man,Thank!!!!!

  8. Masters said on May 11, 2020 at 3:30 am
    Reply

    Hi guys

    It takes 4g ram memory
    or choise other java version

  9. Anonymous said on April 16, 2020 at 12:58 pm
    Reply

    It worked thank you

  10. Karthikeyan S said on October 11, 2019 at 10:53 am
    Reply

    Update the below line will resolve this issue.

    -vm
    C:\Program Files\Java\jre7\bin\client\jvm.dll
    -vmargs

  11. Cameron McKenzie said on October 9, 2019 at 9:18 pm
    Reply

    Quite often a program has a bootstrap file that points to the VM, and if it is not set up correctly, you get this message, even if PATH and JAVA_HOME are set. Here’s a little overview of fixing that exact problem in Eclipse:

    https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-to-fix-the-Eclipse-No-Java-virtual-machine-was-found-install-error?poster=me

  12. Dexter said on August 19, 2019 at 12:47 am
    Reply

    It really worked. I searched a little bit but found different errors, and this worked for me. Thank You very much

  13. Gerold Manders said on August 18, 2019 at 9:58 pm
    Reply

    At work computer (i5, 16GByte RAM) I added the JRE folder (1.8) of another system to the AsciiDocFX editor’s root folder. By doing this, AsciiDocFX can be used as a portable application without the need to have Java installed.

    Thought I tried that after seeing that Oracle database client software (for Windows) uses the same trick. And it works just fine. Created an archive from it and distributed this on several workstations and servers (Intel and AMD). No problem, it works as intended on machines with Windows 7 till Server 2019 and everything in between.

    Now I take that archive home to work on a big documentation project. It extracts just fine, but when I try to start the AsciiDocFX editor, I get a warning message saying that AV software, firewall or heap memory problem prevents the JVM from starting.

    My home machine has Windows 10, 24GByte of RAM and a AMD 4.1GHz A10 (APU) processor. Which is equivalent in processing power as my i5 at work (tested that by re-encoding the same video takes practically the same amount of time on both boxes).

    javaw -XX:+PrintFlagsFinal | find “InitialHeapSize”
    java -XX:+PrintFlagsFinal | find “InitialHeapSize”

    Executing either line at the command prompt (running as admin) results in the message that the JVM cannot be started.

    – Creating a firewall rule or even completely disabling the firewall (incl. reboot) did not help. The problem remains.
    – Disabling the Windows Defender AV (incl. reboot) did not help. The problem remains.
    – Putting the following content in a batch file: \\\bin\java -Xms256m -Xmx512m \\\AsciiDocFX and use that batch file to start AsciiDocFX…did not help. The problem remains.

    At work I applied this trick with 4 other Java based applications and till now I have had no need to install Java on any of my workstations. And these other applications work on my home system too.

    The reboots should have cleared the heap memory from Windows. From the above you could deduce that I am not a fan. Which would be close to the truth. However, because of these “adventures” today, to me Java == filth.

  14. Anonymous said on August 14, 2019 at 10:22 pm
    Reply

    didn’t work for me on windows 10 even on 1024. please update instructions for newer software

  15. Reshma Yadav said on June 3, 2019 at 10:10 am
    Reply

    not working for me while installing eclipse even i have set it 1024. Still getting same error on windows 10. Please suggest solution.

  16. Anonymous said on March 22, 2019 at 2:08 pm
    Reply

    tnx… it worked.

  17. jingwen tang said on March 21, 2019 at 9:23 am
    Reply

    oh,thanks!

  18. Chriza said on February 9, 2019 at 7:19 pm
    Reply

    My game still works, but nothing changed…

  19. Anonymous said on January 30, 2019 at 9:26 am
    Reply

    Brilliant! Thank you very much!

  20. Anonymous said on December 12, 2018 at 6:47 pm
    Reply

    mine is worked. thank you.

  21. Anonymous said on November 10, 2018 at 5:16 am
    Reply

    I think it is because of java. Ex. java 10 do not support other program that use lower version

  22. Anonymous said on September 23, 2018 at 6:42 pm
    Reply

    didn’t work pls help!!!! ive tried just about everything even going up to 4096 NOTHING!!!!!

  23. Anonymous said on September 6, 2018 at 12:32 pm
    Reply

    THANKS

  24. Anonymous said on July 27, 2018 at 4:09 am
    Reply

    WOW! SICK! Nice doesn’t work… send halp just want to play my games.

  25. Anonymous said on July 25, 2018 at 4:58 pm
    Reply

    Thanks. It work for me.

  26. Anonymous said on July 19, 2018 at 12:20 pm
    Reply

    Not working

  27. Anonymous said on July 10, 2018 at 1:56 pm
    Reply

    Its not working for me, could u suggest any other ways to fix the issue

  28. Anonymous said on June 27, 2018 at 11:02 am
    Reply

    It worked
    Thanks

  29. Avijit Samanta said on June 21, 2018 at 4:31 pm
    Reply

    Do not work!!!!!!!!!!!!!!!

  30. Jeetendra said on June 2, 2018 at 6:30 pm
    Reply

    there is a problem to install Eclipse
    could not create java virtual machine

  31. ch appalaraju said on February 5, 2018 at 9:51 am
    Reply

    i was try but it not success plz say to another way

    1. Anonymous said on April 24, 2018 at 6:57 am
      Reply

      Ive tried this and I have had no success but I am with Windows 10. Anyone helps me…

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

    Excelente! :)

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

    yes its works for me…

  34. 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!

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

    its worked for me..thank u

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

    thank you so much

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

    WORKS.Thanks.<3

  38. 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

  39. 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

  40. 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)

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

    thank you

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

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

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

    muchas graaaacias

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

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

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

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

  46. 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?

  47. 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

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

    nice job, it solved a lot problems for me!

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

    Brilliant! Thank you very much!

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

    Thanks! You save my day

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

    Thanks. It worked for me!

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

    thanks very much!

    1. Resuidal rose said on July 13, 2021 at 7:16 pm
      Reply

      delete mc launcher and install it again it might just work

    2. Anonymous said on July 20, 2020 at 5:49 am
      Reply

      mine didnt work sadly

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

      mine does not work

      1. Anonymous said on September 9, 2021 at 12:51 pm
        Reply

        mine also doesnt work

      2. Hrithik said on July 16, 2021 at 7:11 pm
        Reply

        Try this: go to environment variables/ click on edit/ type the variable name ‘Java’ without quotes/ give the location of java.exe in variable value

        Worked for me.

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

        yeah mine dont work either

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

        Doent work

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

        Even mine doesn’t work :(

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.