ClassFormatError
JavaFATALCriticalClasspath

Class file format is invalid

Quick Answer

Check the JDK version — a class compiled with javac 21 cannot run on JRE 17. Verify JAR integrity and clean the build output.

What this means

Thrown by the JVM when a class file violates the Java class file format specification — typically a corrupted JAR, a class compiled for a newer JVM than the one running, or a build artefact that was not fully written.

Why it happens
  1. 1Class was compiled with a newer --release than the target JVM supports
  2. 2JAR file was corrupted during download or extraction
  3. 3Build output directory contains stale or partially-written class files

Fix

Align source/target compiler flags with the JVM version

Align source/target compiler flags with the JVM version
// Maven — ensure compiler release matches runtime JVM
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <release>17</release>
  </configuration>
</plugin>

Why this works

--release controls both the language level and the class file format version. Setting it to the target JVM version prevents UnsupportedClassVersionError / ClassFormatError on older JVMs.

Code examples
Check class file versionjava
# Bash — read major version from class file header
javap -v MyClass.class | grep "major version"
# major version 65 = Java 21
# major version 61 = Java 17
Same error in other languages
Sources
Official documentation ↗

Java SE Documentation

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Java errors