Skip to content

/errors/java/unsupportedclassversionerror

java.lang.UnsupportedClassVersionError: compiled by a more recent version of the Java Runtime

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · openjdk version "17.0.20.1" 2026-08-18updated
tool
Java
exit code
1
versions
Java 8 – 25
os
any

UnsupportedClassVersionError ... has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 61.0 means the .class file targets a newer Java than the JVM running it. The two numbers identify the versions: class file 69 is Java 25, 61 is Java 17. Either run the program on Java 25 or newer, or recompile it with javac --release 17.

Reproduce it

Only a JDK 17 is needed: the class is compiled normally, then its major version field (bytes 6 and 7 of the class file) is set to 69, as if Java 25 had compiled it.

bash
cat > Hello.java <<'EOF'
public class Hello { public static void main(String[] a) { System.out.println("hello"); } }
EOF
javac Hello.java
python -c "
d = bytearray(open('Hello.class','rb').read()); d[6:8] = (69).to_bytes(2,'big')
open('Hello.class','wb').write(d)"
java Hello

Output · exit 1

Error: LinkageError occurred while loading main class Hello
	java.lang.UnsupportedClassVersionError: Hello has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 61.0

Class file versions

Class file versionJava release
52Java 8
55Java 11
61Java 17
65Java 21
69Java 25

Each release adds one: Java 9 is 53, Java 18 is 62, Java 24 is 68. To see what a class targets, use javap -v:

bash
cat > Hello.java <<'EOF'
public class Hello { public static void main(String[] a) { System.out.println("hello"); } }
EOF
javac --release 11 Hello.java
javap -v Hello.class | grep major
java Hello

Output

  major version: 55
hello

Fix: target the older runtime

bash
javac --release 17 -d out src/*.java

--release sets the class file version and also checks that the code only uses APIs of that release, which -source/-target alone do not. In Maven set <maven.compiler.release>17</maven.compiler.release>; in Gradle use java { toolchain { languageVersion = JavaLanguageVersion.of(17) } }.

Sources