Skip to content

Unsupported class file major version 60

Problem Statement

The "unsupported class file major version 60" error occurs when there's a mismatch between your Java version and Gradle version. This error typically appears in IntelliJ IDEA when trying to build a project that works perfectly from the command line.

Major version 60 specifically corresponds to Java 16, but you might encounter this error even when using different Java versions if there's incompatibility with your build tools.

none
* Where:
Initialization script '/tmp/ijmapper.gradle`

* What went wrong:
Could not compile initialization script '/tmp/ijmapper.gradle`.
> Startup failed:
General error during semantic analysis: Unsupported class file major version 60.

Understanding Java Class File Versions

Each Java version has a specific class file major version number:

Java version to class file major version mapping
Java VersionMajor Version
Java SE 2266
Java SE 2165
Java SE 2064
Java SE 1963
Java SE 1862
Java SE 1761
Java SE 1660
Java SE 1559
Java SE 1458
Java SE 1357
Java SE 1256
Java SE 1155
Java SE 1054
Java SE 953
Java SE 852
Java SE 751

Solutions

1. Configure Gradle JVM in IntelliJ IDEA

The most common solution is to ensure IntelliJ uses the correct Java version for Gradle:

  1. Open Settings/Preferences (Ctrl+Alt+S / Cmd+,)
  2. Navigate to Build, Execution, DeploymentBuild ToolsGradle
  3. Under the Gradle JVM option, select a compatible Java version
  4. Click Apply and restart your IDE

INFO

If you're using a newer Java version (16+), make sure your Gradle version supports it by checking the Gradle-Java compatibility matrix.

2. Upgrade Your Gradle Version

Older Gradle versions don't support newer Java releases. Update your Gradle wrapper:

properties
# For Java 16+ compatibility
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip

WARNING

Always check the Gradle-Java compatibility matrix before upgrading to ensure your Gradle version supports your Java version.

3. Verify JAVA_HOME Environment Variable

Ensure your system's JAVA_HOME environment variable points to the correct JDK:

bash
echo $JAVA_HOME  # Linux/Mac
echo %JAVA_HOME% # Windows

The output should show the path to your desired JDK installation.

4. Check Project SDK Settings

In IntelliJ IDEA:

  1. Go to FileProject Structure
  2. Verify the Project SDK and Project language level match your intended Java version
  3. Check Modules to ensure each module uses the correct SDK

5. Clean Java Language Server Workspace (VSCode Users)

If using VSCode, clean the Java cache:

  1. Open command palette (Ctrl+Shift+P / Cmd+Shift+P)
  2. Run Java: Clean Java Language Server Workspace
  3. Restart VSCode

6. For Maven Projects

If using Maven, ensure your plugins are compatible with your Java version:

xml
<!-- pom.xml -->
<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

Check that your junit, surefire, jacoco, and mockito plugin versions are compatible with your JDK.

7. For Android Projects

Android Studio users should:

  1. Go to FileSettingsBuild, Execution, DeploymentBuild ToolsGradle
  2. Change the Gradle JDK to a compatible version (JDK 11 is often safe)
  3. Update your gradle-wrapper.properties to a compatible Gradle version

Common Scenarios

Using Java 16 with Older Gradle Versions

Gradle versions before 7.0 don't support Java 16. Either:

  • Upgrade Gradle to 7.0+
  • Or downgrade Java to version 15 or earlier

Using Java 17 with Gradle

Gradle 7.3+ is required for Java 17 support. For earlier Gradle versions, you'll encounter "unsupported class file major version 61" errors.

Arch Linux/Manjaro Specific Issue

There's a known issue with OpenJDK 16 and Gradle on Arch-based distributions. The solution is to switch to OpenJDK 11:

bash
sudo archlinux-java set java-11-openjdk

Verify with:

bash
archlinux-java status

Prevention

To avoid this issue in the future:

  1. Always check Java-Gradle compatibility before upgrading either
  2. Use Gradle wrapper to ensure consistent builds across environments
  3. Set up your JAVA_HOME environment variable correctly
  4. Regularly update your build tools to maintain compatibility with newer Java versions

TIP

When in doubt, use JDK 11 with Gradle 7.x, as this combination has excellent stability and widespread support.

By following these solutions, you should be able to resolve the "unsupported class file major version" error and get back to productive development in IntelliJ IDEA.