How can I fix "unsupported class file major version 60" in IntelliJ IDEA?
To combat the "unsupported class file major version 60" conundrum, realign your IntelliJ project to Java 16.
Steps:
-
Project SDK: Navigate
File > Project Structure > Project
, select Java 16 SDK. -
Using Maven or Gradle? Fine tune the Java version to 16 in
pom.xml
orbuild.gradle
files:- For Maven:
- Gradle at your service:
- For Maven:
-
Bring in the big guns:
Build > Rebuild Project
.
Congrats! Matching of JDK and class file versions fixes the error. Your error just got a taste of its own medicine!
Fix via Gradle: the detailed walkthrough
Upgrade Gradle: Major version 60 indicates Java 16. Updating to Gradle 7.0 or higher ensures everyone gets along:
Tuning IntelliJ: Adjust Gradle JVM in IntelliJ; select the JDK version that matches your project:
File > Settings > Build, Execution, Deployment > Build Tools > Gradle
Next, under Gradle JVM
, pick the Java version to match with your project - like a puzzle piece!
Environment Variables: Keep JAVA_HOME on the same page with your JDK version:
Switching JDKs: When hitting the wall, JDK 15 is a good alternative. Its compatibility scores well.
Dependencies Compatibility: Ensure all your aliens, ahem, dependencies, can mingle well with Java 16!
Nailing IntelliJ setup with your JDK
Slight Trickery in Project Structure: IntelliJ IDEA's Project Structure dialog can be a sly fox. Double-check the Module SDK in Modules > Dependencies
is set cheerfully to the correct Java SDK.
Refreshing Java Versions: Better close all instances of IntelliJ IDEA or Terminal while making changes - avoiding ghostly caching issues.
Direct Gradle twist in IntelliJ: No luck setting Java 16 from IntelliJ? No worries, build.gradle
has your back:
Deep dive into Gradle: Initialization scripts, mapper file issues are the hidden gems of Gradle configurations that could surface JVM errors in IntelliJ IDEA.
Gradle Distribution URL chess move: Altering the gradle-wrapper.properties
distributionUrl
? Double-check the new Gradle version in IntelliJ's Gradle settings - just like confirming your online order!
Was this article helpful?