Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed when running gradlew run #62

Open
jjhhyyg opened this issue Jul 14, 2022 · 4 comments
Open

Build failed when running gradlew run #62

jjhhyyg opened this issue Jul 14, 2022 · 4 comments

Comments

@jjhhyyg
Copy link

jjhhyyg commented Jul 14, 2022

I used git command to clone this repository, and then execute gradlew run in cmd. Got this problem:

H:\java\onJava\Onjava8-examples>gradlew run

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings generic class cache for settings file 'H:\java\onJava\Onjava8-examples\settings.gradle' (C:\Users\hosealle\.gradle\caches\6.8.1\scripts\75ld31xr8xs8bcp4ekz1dgyh0).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61

* 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 936ms
@SubOptimal
Copy link

You are running Gradle with JDK 17 (based on the error message "Unsupported class file major version 61").

Following the Gradle compatibility matrix JDK 15 is the highest supported Java version for Gradle versions lower than 7.0. The wrapper in the repository is configured to be version 6.8.1.

To solve the issue, the easiest (without changing anything in the repository) would be to run gradlew with a JDK version lower than 16.

Another possibility could be to update the Gradle wrapper to version 7.3 (as this one would support JDK 17). But updating the wrapper probably require other changes too.

@jjhhyyg
Copy link
Author

jjhhyyg commented Jan 3, 2023

I found the solution worked for me: modify the file named java.gradle in the gradle subfolder, change the sourceCompatibility and targetCompatibility to the jdk version you're using, then everything works fine.
image

@jjhhyyg
Copy link
Author

jjhhyyg commented Jan 13, 2023

PS: version above Java14(or 15, 16?) needs higher version of gradle, so the Java 17 is not able to be used in this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@SubOptimal @jjhhyyg and others