Search code examples
eclipsegradleintellij-ideabuildcompiler-errors

Gradle build fails through Terminal but is successful in Eclipse


Task :compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileJava'.

error: invalid source release: 17

I have spent more than 5-6 hours fixing this issue. Due to this i am not able to run my application. Please help me out so that i can proceed

update: I am able to create build successfully in eclipse. but now it is failing with error Error: Could not find or load main class com.abc.ABCServiceApp Caused by: java.lang.ClassNotFoundException: com.abc.ABCServiceApp

and build is still failing through terminal with the same error C:\Users\user\Documents\abc\def\xyzservice>gradle build

Task :compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileJava'.

error: invalid source release: 17

  • 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.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3s 3 actionable tasks: 1 executed, 2 up-to-date

Update: i want to run this project usinh openJDK-15 C:\Users\user1>java -version openjdk version "15" 2020-09-15 OpenJDK Runtime Environment (build 15+36-1562) OpenJDK 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)

Update: i think below is the problem. i want to run my application with java 15, but it is set to java 17, i tried changing it back to 15, but it again get set to 17 enter image description here

Update: lost my patience. Installed another eclipse and it workimg now


Solution

  • It was a IDE issue, somehow it was picking Java17 even though after setting it to 15. Thank you all for your reply. It helped at least to know the root cause. I uninstalled the eclipse and re-installed a fresh one. It works now