[Fixed] Unsupported class file major version 61 in Java

In this post, we will see how to fix Unsupported class file major version 61 in Java.

Reason for Unsupported class file major version 61 in Java

You will get this error when you have compiled the class with Java 17(major version 17) and you are trying to run class file under lower java version (version 16 or below).

All compiled java classes have major version associated with it and it defines which java version has compiled the class.

For example:
Java 17 has major version of 61 where as Java 8 has major version of 52.

Solution for Unsupported class file major version 61 in Java

You can get this issue in scenarios.

Andorid studio/Intellij Idea with gradle

if you are getting this issue with gradle in Android studio/Intellij IDE. You can follow below steps to resolve this.

  • Go to Android Studio --> Preferences.
  • Go to Build, Execution, Deployment --> Build Tools -->Gradle.
  • Change the Java version to either Android Studio default JDK or Embedded JDK.
    Unsupported class file major version 61

You can also try to upgrade the gradle version to fix this issue.

Any other scenario

If maven/gradle is using Java 17 to build the jar, but you are using Java 11 to deploy the jar to production, you will get Unsupported class file major version 61 version.

In general, you should check java version in which you are compiling the class and compare it with java version in which class was compiled.

Please note that different IDEs can have different JDKs to compile the class file. You need to make sure that both compile time and run time environment are same.

Was this post helpful?

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.