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.
* 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 Version | Major Version |
---|---|
Java SE 22 | 66 |
Java SE 21 | 65 |
Java SE 20 | 64 |
Java SE 19 | 63 |
Java SE 18 | 62 |
Java SE 17 | 61 |
Java SE 16 | 60 |
Java SE 15 | 59 |
Java SE 14 | 58 |
Java SE 13 | 57 |
Java SE 12 | 56 |
Java SE 11 | 55 |
Java SE 10 | 54 |
Java SE 9 | 53 |
Java SE 8 | 52 |
Java SE 7 | 51 |
Solutions
1. Configure Gradle JVM in IntelliJ IDEA
The most common solution is to ensure IntelliJ uses the correct Java version for Gradle:
- Open Settings/Preferences (Ctrl+Alt+S / Cmd+,)
- Navigate to Build, Execution, Deployment → Build Tools → Gradle
- Under the Gradle JVM option, select a compatible Java version
- 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:
# 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:
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:
- Go to File → Project Structure
- Verify the Project SDK and Project language level match your intended Java version
- 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:
- Open command palette (Ctrl+Shift+P / Cmd+Shift+P)
- Run Java: Clean Java Language Server Workspace
- Restart VSCode
6. For Maven Projects
If using Maven, ensure your plugins are compatible with your Java version:
<!-- 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:
- Go to File → Settings → Build, Execution, Deployment → Build Tools → Gradle
- Change the Gradle JDK to a compatible version (JDK 11 is often safe)
- 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:
sudo archlinux-java set java-11-openjdk
Verify with:
archlinux-java status
Prevention
To avoid this issue in the future:
- Always check Java-Gradle compatibility before upgrading either
- Use Gradle wrapper to ensure consistent builds across environments
- Set up your
JAVA_HOME
environment variable correctly - 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.