Quick answer: “Error: Could not create the Java Virtual Machine” means Java refused to start because of one of its startup options, not because your program is broken. Look at the line just above the error: it names the bad option. Usually it’s a memory setting that’s too high or badly typed (such as -Xmx4G on 32-bit Java or -Xmx 2g with a space), an option your Java version doesn’t recognize, or a leftover _JAVA_OPTIONS environment variable. Fix or remove that option, and install 64-bit Java if you need more than about 1 GB of memory.
Applies to: Windows 11 and Windows 10, with Java 8, 11, 17, 21 or newer, and apps that run on Java such as Eclipse, Minecraft, Android Studio and Gradle.
In this guide
- What the error means
- Step 1: Read the line above the error
- Fix 1: Remove a bad _JAVA_OPTIONS variable
- Fix 2: Fix the memory setting (-Xmx)
- Fix 3: Remove unrecognized or outdated options
- Fix 4: Use the right Java version (64-bit)
- Eclipse: “Failed to create the Java Virtual Machine”
- Other apps: where their Java settings live
- Related guides
- Frequently asked questions

What the error means
Every Java program runs inside the Java Virtual Machine (JVM). Before it starts, the JVM reads its options from the command line, the app’s settings file and some environment variables. If any of those options is invalid, it stops straight away with:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Reinstalling the app rarely helps, because the bad option usually lives outside it. The fix is to find that option.
Step 1: Read the line above the error
Run the program from a Command Prompt so you can see the full message. For a plain Java program, you can test Java itself with:
java -version
If even that fails, the problem is in your system settings or Java install (Fix 1 or Fix 4). Otherwise, run the app’s own command or launcher and match the line above the error with this table:
| Message above the error | Cause | Go to |
|---|---|---|
Picked up _JAVA_OPTIONS: ... or Picked up JAVA_TOOL_OPTIONS: ... | An environment variable adds options to every Java program | Fix 1 |
Invalid maximum heap size or Invalid initial heap size | The -Xmx or -Xms value is typed wrong | Fix 2 |
Could not reserve enough space for object heap | Java can’t get as much memory as you asked for | Fix 2 and Fix 4 |
Unrecognized option: ... or Unrecognized VM option ... | An option is misspelled or not supported by this Java version | Fix 3 |
Fix 1: Remove a bad _JAVA_OPTIONS variable
Some guides and installers tell you to set _JAVA_OPTIONS (or JAVA_TOOL_OPTIONS) so Java always gets more memory. Every Java program then picks it up, and one bad value breaks all of them. Check whether one is set:
echo %_JAVA_OPTIONS%
echo %JAVA_TOOL_OPTIONS%
echo %JDK_JAVA_OPTIONS%
If a line prints the variable name back unchanged (for example %_JAVA_OPTIONS%), it isn’t set. If it prints options, remove or correct it:
- Press Win, type environment variables and open Edit the system environment variables.
- Select Environment Variables.
- Look in both User variables and System variables for
_JAVA_OPTIONS,JAVA_TOOL_OPTIONSorJDK_JAVA_OPTIONS. - Select it and choose Delete, or Edit it to fix the value. Select OK on every window.
- Close and reopen Command Prompt (and the app) so it picks up the change.
If you really need a memory setting, put it in the app’s own settings instead (see the sections below), so it only affects that app.
Fix 2: Fix the memory setting (-Xmx)

-Xmx sets the most memory Java may use, and -Xms sets how much it starts with. According to Oracle’s documentation, the value is a number followed by k, m or g, written straight after the option:
| Correct | Wrong | Why |
|---|---|---|
-Xmx2g | -Xmx 2g | No space allowed |
-Xmx1024m | -Xmx1024mb or -Xmx1024MB | Use a single letter: k, m or g |
-Xmx2g | -Xmx2.5g | Whole numbers only; use -Xmx2560m instead |
-Xms512m -Xmx2g | -Xms4g -Xmx2g | The starting size can’t be larger than the maximum |
Also keep -Xmx well below your installed RAM, leaving room for Windows and other apps. To see how much you have, go to Settings > System > About and check Installed RAM. On an 8 GB PC, -Xmx4g is usually the most you’d want; most apps need far less.
If you get “Could not reserve enough space” even with a modest value like -Xmx2g, you’re probably running 32-bit Java, which can only use roughly 1 to 1.5 GB on Windows. See Fix 4.
Fix 3: Remove unrecognized or outdated options
Java options change between versions. Settings copied from an old guide or an old version of an app often include options newer Java no longer accepts. A common example is -XX:MaxPermSize (and -XX:PermSize), which belonged to Java 7 and earlier; current Java versions reject or ignore them. Delete those options; the nearest modern setting is -XX:MaxMetaspaceSize, but most people don’t need it at all.
Also check for simple typos: options are case-sensitive, start with a single hyphen (-Xmx, not --Xmx or —Xmx), and curly quotes or long dashes pasted from a web page or Word document will break them. Retype the option by hand if in doubt.
Fix 4: Use the right Java version (64-bit)
Run this in Command Prompt:
java -version
where java
- The first line shows the version, for example
openjdk version "21.0.4". Check what your app needs: newer apps often require Java 17 or 21, while some older ones only work on Java 8. - Look for 64-Bit in the last line. If it’s missing, you’re on 32-bit Java. Uninstall it in Settings > Apps > Installed apps and install a 64-bit build.
where javalists everyjava.exeWindows can find, in order. The first one is the one that runs. If an old version comes first, uninstall it or move the right one higher in the Path variable (same Environment Variables window as Fix 1).
Free, supported Java builds are available from Oracle, from Microsoft (the Microsoft Build of OpenJDK) and from Eclipse Adoptium. You can also install one with winget: run winget search OpenJDK and install the ID it lists. See how to use winget and update from the command line for more.

Eclipse: “Failed to create the Java Virtual Machine”
Eclipse shows this in a small pop-up instead of a command-line message. The settings live in eclipse.ini, in the same folder as eclipse.exe. Make a copy of the file first, then open it in Notepad:
- Find the
-Xmxand-Xmslines below-vmargsand lower them (for example-Xmx2048m), using the rules in Fix 2. - Point Eclipse at a specific 64-bit Java by adding two lines above
-vmargs:-vmon one line, and the full path tojavaw.exeon the next. - Keep each option on its own line, with no spaces at the end, and save the file.
A typical working block looks like this (your Java path will differ):
-vm
C:\Program Files\Java\jdk-21\bin\javaw.exe
-vmargs
-Xms256m
-Xmx2048m
The 64-bit version of Eclipse needs 64-bit Java, and the Eclipse release must support your Java version; recent releases need Java 17 or newer, so check the release notes for your version.
Other apps: where their Java settings live
- Minecraft Launcher: Installations, hover over the installation, select the three dots, then Edit > More options. Fix the JVM arguments box; the
-Xmxvalue there sets how much memory the game gets. - Android Studio and IntelliJ IDEA: Help > Edit Custom VM Options. If the IDE won’t start at all, the file is a
.vmoptionsfile in your user configuration folder; remove the line you last changed. - Gradle builds: check
org.gradle.jvmargsingradle.properties, both in the project folder and in%USERPROFILE%\.gradle. - Batch files and shortcuts: open the
.batfile or the shortcut’s Target box and correct the options afterjava.
If the app starts but then crashes with an access violation instead, see error 0xc0000005: the application was unable to start correctly. If several unrelated apps fail to start, check Windows system files with SFC and DISM.
Related guides
- Error 0xc0000005: the application was unable to start correctly
- Windows Update and winget from the command line
- Windows Resource Protection could not perform the requested operation (SFC and DISM)
- “The instruction at … referenced memory”: when an app crashes with a memory error
Official sources: for more detail, see the official documentation:
- Oracle: The java command (options such as -Xmx, -Xms and JDK_JAVA_OPTIONS)
- Oracle: Environment variables and system properties (JAVA_TOOL_OPTIONS)
- Microsoft Learn: Install the Microsoft Build of OpenJDK
Frequently asked questions
Should I run the app as administrator?
It rarely helps with this error. The JVM fails because of its options, not permissions. Fix the option named above the error instead.
How much memory should I give Java?
Only what the app needs. Many apps run fine with 1 to 2 GB; large IDEs or modded games may want 4 GB. Giving Java most of your RAM slows down everything else.
Why does every Java program fail, not just one?
That points to a system-wide setting, almost always a _JAVA_OPTIONS or JAVA_TOOL_OPTIONS variable (Fix 1), or a broken Java install first in your Path (Fix 4).
Do I need to uninstall old Java versions?
Not always, but old 32-bit or outdated versions often end up being the one that runs. Removing the ones you don’t need avoids surprises and closes old security holes.
Leave a Reply