I try build gradle project and get error:
Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_144 contains a valid JDK installation.
I add to path
C:\Program Files\Java\jdk1.8.0_112\bin
C:\Program Files\Java\jre1.8.0_144\bin
when I write java and javac in console all works. But project not build
The Jar is created under the $project/build/libs/ folder.
The problem is with version of JDK you are using. The Intellij version 2020.2 supports only upto JDK 14. So either you have to lower the JDK version to 14 or update the IntelliJ to a newer version like 2021.
First of all Download And Install the JDK from the Oracle website with the same version number as the JRE if you didn't already. Then add JAVA_HOME to the environment variables of Windows. Restart your terminal or development environment to load the new JAVA_HOME value. Now, Your error must be solved.
The reason it works in your console is because your console is most likely picking up its JDK from your JAVA_HOME value in your environment settings.
For Gradle, you need to create a gradle.properties file in your application's root directory (if it does not already exist) and add the following line:
org.gradle.java.home=C:/path/to/your/jdk
When you copy your path from the Windows Explorer, please remember to change "\" to "/", otherwise, they will be escaped and you will receive an error inside of Eclipse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With