How to Fix ‘Could Not Create the Java Virtual Machine’ Error in Applications?

When attempting to run certain applications or games, such as Hexxit II or Technic Launcher, users may encounter the “Could Not Create the Java Virtual Machine” error, which immediately stops the process. This error indicates that the Java Virtual Machine (JVM) — essential for running Java applications — cannot initialize due to specific issues.

The most common cause of this error is insufficient memory allocation or incorrect settings preventing the JVM from using the necessary resources. Other possible factors include outdated Java versions, configuration errors, or system limitations.

1. Add the _JAVA_OPTIONS to System Variables

Setting the _JAVA_OPTIONS variable in System Variables creates a universal setting for Java. It specifies a maximum heap size for the JVM, preventing memory errors like “Could Not Create the Java Virtual Machine.” For example, -Xmx512M limits Java to 512 MB of memory, ensuring a consistent setup and reducing crashes.

  1. Press Windows key + R, type “sysdm.cpl”, and press Enter to open System Properties.
  2. In System Properties, go to the Advanced tab and click Environment Variables.
  3. In Environment Variables, click New under System Variables.
  4. Set Variable name to _JAVA_OPTIONS and Variable value to Xmx512M, then click OK.
  5. Close the windows and restart your computer to apply the changes.
  6. After restarting, open the application with the error to check if it works now.

2. Add the Java Bin Path to the System Environment Variable

Adding the Java Bin Path to the System Environment Variable helps the system find java.exe, ensuring Java runs properly. This makes Java accessible from anywhere on your system, avoiding errors.

  1. Open File Explorer with Win + E keys.
  2. Go to:
    C:\Program Files\Java\jdk-19\bin
    Your system may have a different JDK version installed.
  3. Copy the Java path from the address bar.
  4. Press the Win key and type “About your PC”.
  5. Press Enter to open settings.
  6. Click Advanced System Settings, then Environment Variables.
  7. Double-click Path under System Variables.
  8. Click New and paste the path.
  9. Click OK and run the program to check if the error is resolved.

3. Remove _JAVA_OPTIONS From System and User Variables

Sometimes, hidden settings can affect Java’s operation. The _JAVA_OPTIONS variable can override system settings. Removing _JAVA_OPTIONS ensures Java uses the correct memory and performance settings, preventing errors like “Could Not Create the Java Virtual Machine.”

  1. Press the Win key and type Notepad.
  2. Right-click Notepad and select Run as administrator.
  3. In Notepad, type:
    @ECHO off
    SETX _JAVA_OPTIONS "" /m
    SETX _JAVA_OPTIONS ""
    PAUSE

  4. Press Ctrl + S to save.
  5. Include the .bat extension when saving.
  6. Run the batch file as administrator and check if it works.

4. Reinstall Java

If previous solutions haven’t worked, reinstalling Java might help. This removes corrupted files and outdated components, ensuring you have the latest version. A clean installation often fixes hidden issues and provides a stable setup for Java applications.

  1. Press Windows key + R and type “appwiz.cpl“.
  2. Press Enter to open Programs and Features.
  3. Find Java, right-click, and select Uninstall.
  4. Delete all Java instances and restart your computer.
  5. After rebooting, download the latest JRE from here.
  6. If the issue persists, install the latest JDK from here.
    Note: Consider changing JDK versions or uninstalling JRE if installed.
  7. Verify if the issue is resolved.
ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.

Comments

7
    JW
    JonJen Wolfe Jul 18, 2019

    So if both of these steps have been completed…
    Full uninstall of all JAVA files and folders…
    Attempted to install in compatibility mode…
    Attempted online install…
    Offline Install of 32 and 64bit (comp is 64)…
    And I still get the same ERROR: Could not create the Java Virtual Machine.

    What can I do?

    I don’t even have JAVA installed on my machine now and its really limiting as you can imagine.

      SW
      Shane Warren Author Sep 8, 2019

      Have u tried the first method? that is the one which works for most users

        SG
        Sky_Gashrod Oct 10, 2019

        doen’t work for me what can i do i’ve tried both method and still not working

          RG
          Raj Guru Jan 10, 2020

          May be u have alloted too much ram for Minecraft under jvm script. Lower it and the problem will be fixed.

    IK
    Ian Koval Nov 6, 2021

    GUYS I FIGURED IT OUT. Holy cow I’ve been trying to fix this for days. Every guide on the internet failed me. If the System Variable fix didn’t work for you, Go to the Environment Variables tab and use a SINGLE HYPHEN instead of the double as suggested in this guide. Apparently double hyphens can cause issues and mine works like a charm with this modification. Note the single hyphen in front of the argument below:-Xmx512MHope this helps anybody else who’s stuck!

      TA
      Tasenova Dec 3, 2021

      HEY THANK YOU MAN< MUCH APPRECIATED