To this day, Java is a popular programming language. It may be old, but it hasn’t lost its popularity or utility over time. It is still in active development and is used by many developers. Changes and improvements to the language are developed on a regular basis, making it incredibly simple to compile and run Java-based applications.
How to fix “Could not create the Java virtual machine”

Fix Could not create the Java virtual machine

When compiling code in an IDE, the message “Could not create the Java virtual machine” is common. The error isn’t specific enough to alert customers to the particular problem, although it’s usually caused by;

  • Incorrect Java version being used
  • Also Incorrect SDK version installed
  • Incorrect environment variables set up
  • Syntax errors when declaring the version of Java that is to be used
  • Missing libraries in the IDE
  • Errors in memory management

1. Check compatible Java version

When code is compiled in an IDE, the message Could not create the Java virtual machine displays. This occurs because the IDE is incompatible with the Java version installed on your computer.

Check to see which Java versions your IDE supports. Next, determine which version of Java is installed and compare it to the supported version. Install the proper version if it isn’t already installed.

2. Check Environment variables

On Windows 10, the Java parameters set in the Environment variables can result in the Could not create the Java virtual machine problem.

  1. Open File Explorer.
  2. Paste this explorer shell:::{BB06C0E4-D293-4f75-8A90-CB05B6477EEE} in the location bar and tap Enter.
  3. Click Advanced System Settings in the panel on the left.
  4. Go to the Advanced tab.
  5. Select Environment Variables and click New under System Variables.
  6. Enter _JAVA_OPTIONS in the name field.
  7. In the path/value, enter: -Xmx1024M
  8. Click OK.
  9. Restart the app.

You should also double-check that the right path for the Java SDK is specified.

  1. Open File Explorer and go to C:\Program Files\Java
  2. Open the folder for the JDK version you want to use.
  3. Copy the path to the folder.
  4. Open Environment variables (see previous steps).
  5. Under System variables, select JAVA_HOME.
  6. Click Edit.
  7. Enter the path that you copied and click OK.
How to fix “Could not create the Java virtual machine”

3. Check startup arguments

Examine the startup arguments you’ve specified. Although you may have the correct version of Java installed, the startup arguments may have changed the version to be used for compilation. If you did an in-place Java upgrade, it’s very likely that the startup arguments still refer to the earlier version.

Related: How to fix DisplayPort to HDMI adapter not working

4. Check syntax

Make sure the syntax is proper for any arguments you’re entering. The Could not create the Java virtual machine problem can be caused by even the tiniest fault. Look for an extra hyphen or an incorrectly reported version.

5. Reinstall Java

Reinstall Java if necessary. It might help you open an IDE or other comparable app if you’re encountering issues.

  1. Open Control Panel.
  2. Go to Programs>Uninstall a program.
  3. Look for Java and select it.
  4. Click the Uninstall button at the top.
  5. Allow Java to uninstall.
  6. Download and install Java again from here.

6. Check memory allocation

Insufficient memory allocated for use is one of the main causes of the Could not create the Java virtual machine issue.

  1. Open File Explorer. 
  2. Go to C:\Program Files\Java
  3. Open the JDK folder with the currently installed version number.
  4. Look for a file called jvisualvm.exe and run it.
  5. The app will provide a GUI for managing memory.
  6. Increase the amount of memory and try again.

Related: How to Fix VLC error Libvlc.dll Is Missing on Windows 10


It can take a long time to set up a development environment. Before you can write or compile code, you’ll need to set up a lot of things and meet a lot of prerequisites. These problems aren’t specific to Java; every language has its own set of prerequisites that must be completed before it can be used.