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
This happens when JDK and JRE have different versions installed on your system. Update the JDK with the matching version of JRE. Also verify that System variable path has bin value from same JDK version.
This can occur if your path is too long as well. I solved this by moving my java install to
C:\Java\jdk1.8.0_211
I had the same problem and fixed it like this:
The problem is your gradle build is not finding the JAVA_HOME path or JDK folder. So, you could declare the path in gradle.properties like org.gradle.java.home=C:\Program Files\Java\[or yours jdk folder name].
Use this guide for using gradle.properties.
Or (and I prefer this solution) include JAVA_HOME path in systmem variables and restart CMD.
My error was solved by uninstalling all java updates and java from control panel and reinstalling JDK
In Eclipse
Right click Project --> Java Build Path --> Libraries