Fix "A Java Exception has occurred" When Opening a Server Jar

Updated · MCJarHub

This Windows popup only says that Java crashed — it hides the actual error. Start the jar from Command Prompt with java -jar server.jar nogui to read the real message; for server jars it is almost always an UnsupportedClassVersionError caused by an old Java.

What you see

You double-click a server jar on Windows and get a small dialog titled Java Virtual Machine Launcher with the text:

A Java Exception has occurred.

That popup is generic: Windows started the jar with javaw.exe, which has no console, so Java can only tell you that something failed, not what. You need to run the jar from a command prompt to see the real error.

Step 1: see the real error

  1. Open the folder containing the jar in Explorer.
  2. Click the address bar, type cmd and press Enter — a Command Prompt opens in that folder.
  3. Run the jar (use its real file name):
java -version
java -Xms2G -Xmx2G -jar server.jar nogui

The first command shows which Java Windows uses; the second prints the actual error.

Step 2: match the message

Message in the consoleCause and fix
UnsupportedClassVersionError … class file version 65.0 (often after Error: A JNI error has occurred) Your Java is too old for the jar — by far the most common cause. Install the Java the server needs and use it: UnsupportedClassVersionError fix.
Error: Invalid or corrupt jarfile server.jar Broken or incomplete download. Download again and compare the checksum shown on the version page (how to verify).
Error: Unable to access jarfile server.jar Wrong file name or folder — run dir to see the real name (it may be server.jar.jar).
You need to agree to the EULA…, then the server stops Not an error: accept the EULA in eula.txt and start again.
Invalid maximum heap size or Could not reserve enough space for object heap -Xmx is larger than the memory available — or you are on a 32-bit Java, which cannot use more than a small heap. Lower -Xmx or install a 64-bit Java. See how much RAM a server needs.

Why double-clicking picks the wrong Java

The .jar file association points to whichever Java installer registered it last — often an old Java 8 installed years ago for another program. Installing a newer Java does not always update it. Instead of relying on double-click, use a start.bat next to the jar that calls the right Java explicitly:

@echo off
cd /d "%~dp0"
REM adjust to the Java folder you installed (dir "C:\Program Files\Eclipse Adoptium")
"C:\Program Files\Eclipse Adoptium\jdk-21.0.8.9-hotspot\bin\java.exe" -Xms4G -Xmx4G -jar server.jar nogui
pause

The pause keeps the window open so any future error stays readable. The start script generator builds this file for your server type, version and RAM. Which Java you need depends on the Minecraft version — see the Java version table.

FAQ

Why does double-clicking use the wrong Java?
Windows opens .jar files with whichever Java registered the file association, often an old Java 8 from years ago — even if a newer Java is installed.
Should I uninstall old Java versions?
Not required, but removing Java versions you no longer need avoids the wrong one being picked. Otherwise use the full path to the correct java.exe in start.bat.