Even though I manually configured JDK project structure file/Project structure it still shows this error FAILURE: Build failed with an exception.
`What went wrong: Execution failed for task ':sample:compileReleaseJavaWithJavac'.
Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_151 contains a valid JDK installation.`
I'm confused why it is still looking for C:\Program Files\Java\jre1.8.0_151 instead of JDK
Copy tools.jar from
C:\Program Files\Java\jdk1.8.0_121\lib
toC:\Program Files\Java\jre1.8\lib
.It's resolved the problem now.
for tools.jar is in C:\Program Files\Java\jdk1.8.0_201\lib. I changed installed jre in eclipse. Windows->Preferences->Java->installed JREs and make default jre to point to where your jdk is.
you have to added jdk path org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_102 to gradle.properties make sure you write your jdk version which installed in you system.