Unsupported class file major version 61 error in Java

If you are seeing the following error:

java.lang.IllegalArgumentException: Unsupported class file major version 61

This is because you are trying to execute a Java app (or class) that was compiled using a newer version of JDK than the one you have installed. Java class files have a major version number that corresponds to the JDK version that was used to compile them. When you run a class file with a major version that is higher than the version of the JDK you have installed, you will see this error message. In this case, the class was compiled using Java 17 (major version 61) and you are running it with Java 16 or below.

To resolve this error, you will need to upgrade your JDK to a newer version that supports the major version of the class file you are trying to run. First check the major version of the class file that you are trying to run:

$ javap -verbose Main.class | grep "major"
  major version: 52

Next, check the JDK version matching major version from the table below. Next download and installed the corresponding version of the JDK on your machine. Run the file again and it should work.

Major version Java
63 Java 19
62 Java 18
61 Java 17
60 Java 16
59 Java 15
58 Java 14
57 Java 13
56 Java 12
55 Java 11
54 Java 10
53 Java 9
52 Java 8
51 Java 7

Speak Your Mind