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 frustrating “Could Not Create the Java Virtual Machine” error, which immediately halts 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 allocating the necessary resources​​​​. Other possible factors include outdated Java versions, configuration errors, or system limitations.

Method 1: Add the _JAVA_OPTIONS to System Variables

Many affected users have managed to resolve the issue by creating a System Variable for Java called _JAVA_OPTIONS and setting its value to Xmx512M. This action sets the global maximum heap memory size for Java.

This will resolve any error message occurring because the maximum heap memory size of the started Java application is larger than the one set as the System Variable. Several users who encountered the same issue reported it was resolved entirely after following the steps below.

  1. Press the Windows key + R to open a Run dialog box. Then, type “sysdm.cpl” and press Enter to open the System Properties screen.
  2. Inside the System Properties screen, go to the Advanced tab and click on Environment Variables.
  3. In the Environment Variables window, click on New (under System Variables).
  4. In the New System Variable window, set the Variable name to _JAVA_OPTIONS and the Variable value to Xmx512M, then click OK to save the changes.
  5. Close the previously opened windows and restart your machine to apply the changes.
  6. At the next startup, open the application that was previously displaying the “Could Not Create the Java Virtual Machine” error and check if it is now functioning properly.

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

Some programs and processes require specific environments to run on the system. Windows needs to recognize these environments, storing the necessary information in different paths within the system environment variable.

This error occurs when Windows lacks information about the Java executable file. Here is where environment variables come into play. You need to define the Java path in the environment variable so that Windows knows exactly where to locate the Java executable file when a program requires it.

This step is necessary regardless of which program displays this error. If Java is installed, check the environment variables to verify that Windows is aware of its installation.

  1. Open the File Explorer using the Win + E keys simultaneously.
  2. Navigate to the following path:
    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. Then, press the Win key and type “About your PC.”
  5. Hit Enter to open the settings.
  6. Click on Advanced System Settings, then click Environment Variables.
  7. Double-click the Path under System Variables from the list of options.
  8. Click New on the right side and paste the copied path here.
  9. After completing this step, click OK. Then, run the program and check if the error has been resolved.

3. Remove _JAVA_OPTIONS From System and User Variables

In the first method, we instructed you to add the _JAVA_OPTIONS as an environment variable. However, if that method does not work, you can try removing _JAVA_OPTIONS from both system and user environment variables.

For convenience, you can create a bat file to simplify the process of removing _JAVA_OPTIONS from the system and user environment variables.

  1. Press the Win key and type Notepad.
  2. Right-click on Notepad and select Run as administrator.
  3. Type the following code into Notepad:
    @ECHO off

  4. Press Ctrl + S to save the file.
  5. When saving the file, ensure to include the .bat extension in the filename.
  6. Run the bat file as an administrator and check to see if this method has worked.

4. Reinstall Java

If the problem persists, it could be due to improper Java installation or having an incorrect version of Java installed. You need to determine which version of Java is required by the app displaying the error.

Most applications necessitate having the latest Java version installed. After reinstalling the correct Java version, be sure to add the Java path to the environment variables by following the second method.

  1. Press the Windows key + R to open the Run prompt and type in “Appwiz.cpl“.
  2. Press “Enter” to open the Programs and Features screen.
  3. Scroll through the installed application list at the Programs and Features screen until you find Java.
  4. Right-click on Java and select Uninstall to remove it completely from your system.
  5. Begin by deleting the primary Java installation and then proceed to remove all other instances, such as updates and different versions.
  6. After completing all uninstalls, restart your computer.
  7. Upon rebooting, visit this link to download the latest version of JRE.
  8. Check to see if the issue continues to occur.
  9. If the error still persists, download and install the latest version of JDK from here.
    Note: If you are currently using JDK, consider changing its versions or uninstall the JRE that was installed alongside it.
  10. Verify if the issue is still present.

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.