When launching Arduino IDE on Windows, you may get this error:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Arduino IDE comes bundled with its own Java Runtime Environment, located within the application folder. You are not required to install Java yourself on your system. The error indicates that the Java Virtual Machine (JVM) could not be started, which can be caused by corrupted or incorrectly configured files in the Arduino IDE application folder, or conflicting system-level configuration for the Java environment.
One reason for the error can be an improper option set in the
Open the Arduino IDE application folder, by default
C:\Program Files (x86)\Arduino.
Open the file
arduino.l4j.iniwith a text editor.
Find the line starting with
-Xmx. By default, it should be
-Xmx512M. If this is not the case, change the line to read
Try launching Arduino IDE again.
arduino_debug.exe and check environmental variables
_JAVA_OPTIONS environmental variable has been set, it can interfere with Arduino IDE. You can check this by running
Open the Arduino IDE application folder, located in
C:\Program Files (x86)\Arduinoby default.
arduino_debug.exeand observe the output.
_JAVA_OPTIONS has been set, you will get an output like this:
Picked up _JAVA_OPTIONS: -Xmx2G
Error occurred during initialization of VM
Could not reserve enough space for object heap
In this case, consider editing or removing it:
Since changing or removing environment variables can affect other applications on your computer, it’s recommended to save the value in case you want to restore it later.
Press Win + X or right-click the Start menu button to open the Power User menu.
In the Power User Task Menu, select the System option.
Click the Advanced System Settings link in the left column.
In the System Properties window, click the Advanced tab, then click the Environment Variables button near the bottom of that tab.
Under User variables for User, look for a
_JAVA_OPTIONSvariable. If there is one, click on it to select it, then either click Delete to remove it, or click Edit and remove the
-Xmxoption. Then do the same for System variables.
Click OK to close the Environment Variables window.
Click Apply to apply the changes.
Reinstall Arduino IDE
_JAVA_OPTIONS variable is not set, reinstalling Arduino IDE is likely to resolve the issue. Get it from the software page.
Use Arduino IDE 2
Newer versions of Arduino IDE runs without Java, avoiding the problem altogether. Get it here.