If you have downloaded a String Boot project template with Gradle as a build tool and Java JDK 20 from start.spring.io Spring Initializr website, and when you import it to IntelliJ IDE you get "Unsupported class file major version 64" error, below are the steps to fix this issue.
FAILURE: Build failed with an exception.
* What went wrong:
Could not open init generic class cache for initialization
script '/private/var/.../T/ijresolvers.gradle'
(/Users/c2c/.gradle/caches/7.6.1/scripts/aejjxle1g2p4skw2suq76iht6).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_'
Unsupported class file major version 64
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 657ms
Fix:
- Open your project in IntelliJ IDE.
- Now go to Menu: View -> Tool Window -> Gradle.
- Click on the tool icon, and select Gradle Settings...
- Make sure the "Use Gradle from" is set to "gradle-wrapper.properties"
- Lower the Gradle JVM to a version of Java JDK lower than 20 (say 19, 18 or 17)

- Click Apply and Close.
Now when you will refresh Gradle, this issue will go way and you will be able to download all Spring Boot related dependencies and run your project!
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!


Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!