Skip to main content
Early Access: MineXHost is live and still being built. Expect maintenance and occasional outages. Check live status

“Error: Could not create the Java Virtual Machine” and “Invalid maximum heap size” on a Minecraft server

Updated 5 min read By MineXHost

Java checks its command-line options before it starts anything. When one is malformed or contradictory, it prints what it rejected and exits, so Minecraft never runs and nothing reaches logs/latest.log. On a Minecraft server the culprit is almost always the memory flag.

Which message did you get?

What the console saysWhat Java rejectedFix
Invalid maximum heap size: -XmxA space after -Xmx, so the value was read separately.Attach the value: -Xmx6G.
Invalid maximum heap size: -Xmx4GBA two-letter unit. Java accepts K, M or G only.-Xmx4G or -Xmx4096M.
Invalid maximum heap size: -Xmx1,5GA decimal. The number must be whole.-Xmx1536M.
Error occurred during initialization of VM / Too small maximum heapNo unit, so Java read the number as bytes.Add M or G: -Xmx4096M.
Initial heap size set to a larger value than the maximum heap size-Xms is bigger than -Xmx.Make -Xms equal to -Xmx or smaller.
Unrecognized VM option '…'A flag the installed Java does not know.Delete that flag.

The three Invalid maximum heap size rows and the Unrecognized VM option row end with Error: Could not create the Java Virtual Machine. The no-unit row and the -Xms row print Error occurred during initialization of VM instead, with the reason (Too small maximum heap, or Initial heap size set to a larger value than the maximum heap size) on the next line.

How to fix it

  1. Find the java command: your start script (start.sh, run.bat), your host's startup setting, or on modern Forge and NeoForge the user_jvm_args.txt file.
  2. Read the line just above Could not create the Java Virtual Machine. It names the option Java rejected.
  3. Write memory flags as a whole number plus one letter, with no space: -Xmx6G or -Xmx6144M. Not -Xmx 6G, -Xmx6GB, -Xmx6.5G or -Xmx6144.
  4. Keep -Xms the same as -Xmx or smaller.
  5. Do not set -Xmx to all of the machine's or plan's memory. Java also uses memory outside the heap for loaded classes, threads and network buffers, so leave headroom.
  6. If Java names an unrecognised option, remove it. Flag lists copied from guides are often written for a different Java version.
  7. On Forge or NeoForge with run.sh or run.bat, put memory flags in user_jvm_args.txt, one per line.

Note

A very large -Xmx is usually not what stops a 64-bit Java from starting. Java accepts a heap bigger than the machine has and fails later, with an out-of-memory crash or a kill. A refusal to start is almost always a typing problem in the flag.

How much heap a modpack needs depends on the pack and the player count. The RAM calculator gives an estimated figure to start from.

Open the RAM calculator

When the server starts and then runs out of heap, the error is different: java.lang.OutOfMemoryError.

Read the OutOfMemoryError guide

What MineXHost's launcher does with this crash

On MineXHost you do not write -Xmx yourself. MineXEngine, our launcher, sets the Java heap from your plan's memory, leaves room for the memory Java uses outside the heap, and writes both memory flags as whole megabytes, with -Xms never above -Xmx. On Forge and NeoForge it writes user_jvm_args.txt itself, so a memory flag shipped inside a pack does not survive into the launch.

If Java still refuses to start, the engine removes only the extra startup flags it added itself and tries again. A rejected flag that is not one of its own is left alone. If the process keeps dying the instant it starts, the engine tries a different Java version once, then stops and asks you to contact support rather than restarting forever. It does not change your plan's memory.

Unrecognised options often come from flags written for another Java version. Check which Java your Minecraft version needs.

Look up the Java version

MineXHost runs Forge, NeoForge, Fabric and Paper servers on MineXEngine. Our launcher detects the modpack, picks the right Minecraft loader and Java version, tunes the JVM for your RAM, and auto-recovers from the crashes that normally end a modded server's evening. Pick your RAM, paste the pack, and play.

See hosting plans

Frequently asked questions

What does “Invalid maximum heap size” mean on a Minecraft server?

Invalid maximum heap size means Java could not read the -Xmx value in your start command, usually because of a space after -Xmx, a two-letter unit such as GB, a decimal comma, or a number too large to represent, so it stops with Could not create the Java Virtual Machine before Minecraft starts. Write it as -Xmx6G or -Xmx6144M.

How much -Xmx should a Minecraft server have?

A Minecraft server's -Xmx should be set below the total memory the server or plan has, not equal to it, because Java also uses memory outside the heap for loaded classes, threads and network buffers, and a heap set to the full limit gets the process killed when the total runs over. Heavier modpacks need more; start from an estimate.

Can setting -Xmx too high stop the server from starting?

On a 64-bit Java, an -Xmx larger than the machine's physical memory is usually accepted at start-up because Java only reserves address space, so the usual result is a later out-of-memory crash or kill rather than Could not create the Java Virtual Machine. A malformed value is the more common cause of a refusal to start.

What does “Error occurred during initialization of VM” mean?

Error occurred during initialization of VM means Java accepted the syntax of your options but found their values unusable, for example a starting heap (-Xms) larger than the maximum (-Xmx), or a heap size with no unit, which Java reads as bytes and rejects as Too small maximum heap. The line under it names the exact problem.

Still stuck?

Every ticket is answered by a real person who plays Minecraft and knows modpacks. Send the full console output, not just the last line. Customers open a ticket from the panel; anyone can ask in our Discord.

  • Live support 5PM-12AM ET on weekdays
  • Replies typically within 12 hours
  • Limited availability on weekends