Friday, May 15, 2020

Gradle error : compileJava FAILED

If you have seen above error , reason may be you have not set JAVA_HOME properly.
you can check with simply running "echo %JAVA_HOME%" in windows. If output is "%JAVA_HOME%" that means JAVA_HOME is not set properly.

Below is a sample scenario
1. Run "gradle build"  --> fail with compileJava FAILED
2. We set JAVA_HOME
3. Check whether JAVA_HOME is set
4. Re run "gradle build"

---------------------------------------------------------------------------------------------------

Microsoft Windows [Version 10.0.17134.1425]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\register-server>gradle build
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_171 contains a valid JDK installation.

* 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 22s
1 actionable task: 1 executed

C:\register-server>echo %JAVA_HOME%
%JAVA_HOME%

C:\register-server>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161

C:\register-server>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_161




No comments:

Post a Comment