ClassFormatError: Unsupported Major.Minor Version
java.lang.UnsupportedClassVersionError: com/example/MyClass has been compiled by a more recent version of the Java RuntimeQuick Answer
The class was compiled with a newer Java version than you are running. Upgrade your JRE or recompile with a compatible target version.
Why This Happens
Each Java version produces class files with a specific major version number. Java 17 classes have version 61, Java 11 has 55, Java 8 has 52. Running a class compiled with a newer Java on an older JRE produces this error.
The Problem
# Compiled with Java 17
javac --release 17 MyClass.java
# Running with Java 11
java -cp . MyClass # UnsupportedClassVersionErrorThe Fix
# Option 1: Run with Java 17
export JAVA_HOME=/path/to/java17
java -cp . MyClass
# Option 2: Compile for Java 11 compatibility
javac --release 11 MyClass.javaStep-by-Step Fix
- 1
Identify the version mismatch
Read the error for the class version number. Java 8=52, 11=55, 17=61, 21=65.
- 2
Check your JRE version
Run java -version to see what version you are running.
- 3
Upgrade JRE or recompile
Either upgrade to a JRE that supports the class version, or recompile with --release flag targeting the older version.
Bugsly catches this automatically
Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.
Try Bugsly free