Fix: Spring Boot + IntelliJ + Gradle : Unsupported class file major version 64 Error


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:

  1. Open your project in IntelliJ IDE.
  2. Now go to Menu: View -> Tool Window -> Gradle.
    Tools - Gradle in IntelliJ Option
  3. Click on the tool icon, and select Gradle Settings...
    Select Gradle Settings
  4. Make sure the "Use Gradle from" is set to "gradle-wrapper.properties"
  5. Lower the Gradle JVM to a version of Java JDK lower than 20 (say 19, 18 or 17)
    Set a lower Gradle JVM Version say JDK 17
  6. 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!


Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap