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!
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Gradle,
- Run only a Single Unit Test using Gradle
- Run IntelliJ Java main method without Gradle build
- How to force re-download Gradle Dependencies
- How to Run Gradle Build Without Unit Test Cases
- Find installed Gradle version command
- Fix: Invalid Gradle JDK configuration found. Could not find the required JavaSDK
- Generate Project Dependency tree using Gradle Command
- Installing Gradle on macOS - Gradle Tutorial
- Gradle FAILURE: Build failed with an exception - Task not found in root project
- [Fix] ./gradlew: Permission denied
- Force Gradle to use specific Java JDK Version
- [fix] Deprecated gradle features were used in this build, making it incompatible with Gradle X.0
- Create a Gradle Java Project in VS Code
- Install Gradle VS Code for Java Projects
- Fix: Unsupported Java. Your build is currently configured to use Java 17.0.5 and Gradle 7.1.
- How to create Gradle Multi-Project in IntelliJ
- Fix: Spring Boot + IntelliJ + Gradle : Unsupported class file major version 64 Error
- Fix: Error: Could not find or load main class org.gradle.wrapper. GradleWrapperMain
- [fix] bash: gradlew: command not found
- [fix] Execution failed for task :core:compileJava - Could not find tools.jar
- Run Gradle Build without test cases
- How to add maven central repository in build.gradle
- Upgrade Gradle in Android Studio
- Task is ambiguous in root project gradle-examples. Candidates are: myTask1, myTask2
- Fix: Deprecated Gradle features were used in this build, making it incompatible with Gradle
More Posts:
- Java Jackson ObjectMapper Class with Examples - Java
- How to create Custom RatingBar Android Programming Tutorial - Android
- How to Transpose a Square Matrix - Java Program - Java
- How to create Toast messages in Android? - Android
- Google Chrome Update failed (error: 12) - Chrome
- PowerShell SubString with Examples - Powershell
- HTML Images - Attributes and Formats - Html
- How to install Postman natively on a Mac - HowTos