Java – Unsupported class file major version 61
It means Java 17 (major version 61) compiled the class file, and if we try to run the class file under Java 16 and below environment, and we will hit Unsupported class file major version 61.
1. Find the major version of the Java class file
Every compiled Java class file, or .class
has a major version to tell which Java version compiled the class; For example, Java 17 (major version 61), Java 11 (55), Java 8 (52).
Java SE | Major Version | Hex |
---|---|---|
17 | 61 | 0x3D |
11 | 55 | 0x37 |
9 | 53 | 0x35 |
8 | 52 | 0x34 |
Note
Review this table for a complete list of a major versions of the Java class file.
2. Unsupported class file major version XX
Let’s say, Maven is using Java 11 (major version 55) to package the jar
file, and we deploy it to a production server using Java 8, and we will hit Unsupported class file major version 55.
Let’s say Gradle is using Java 8 (major version 52) to package the jar
file, and we deploy it to a production server using Java 1.4, and we will hit Unsupported class file major version 52.
Note
IntelliJ IDEA, Eclipse, JAVA_HOME PATH, Maven, and Gradle may configure different JDK to compile the source code or class file. We need to ensure both the Java compile (compile the class) and runtime (run the class) environment is the same.
I’m lost. I am just a user and the latest download of the JRE is 8. So how can a developer develop something that is a later version? I see Java up to version 20. Very confusing. When I go to a command prompt and look at a version (or the configure java app), I see : java version “1.8.0_351”
Java(TM) SE Runtime Environment (build 1.8.0_351-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.351-b10, mixed mode) I’m lost.
Since java 8, the JRE and JDK are packaged together and cannot be downloaded separately (through the official channels at least). That is why the latest JRE that you can find is 8.
There’s multiple java (runtime / langauge / standard library / vendor) versions being supported concurrently similar to how windows 10 and windows 11 continue to be sold and receive updates. On top of that, there’s also some licensing issues with later versions of java as (partially) covered in this wikipedia article: https://en.wikipedia.org/wiki/Java_version_history