Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_151 contains a valid JDK installation

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

like image 613
Viswesvar Sekar Avatar asked Nov 14 '17 16:11

Viswesvar Sekar


People also ask

Could not find tools jar in JRE?

I had the same problem and fixed it like this: Install the JDK from the Oracle website with the same version number as the JRE if you didn't already. Furthermore add JAVA_HOME to the environment variables of Windows. Restart your terminal or development environment to load the new JAVA_HOME value.

Can not determine path to Tools jar?

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.

What is the use of tools jar in Java?

The jar command is a general-purpose archiving and compression tool, based on the ZIP and ZLIB compression formats. Initially, the jar command was designed to package Java applets or applications; however, beginning with JDK 9, users can use the jar command to create modular JARs.


3 Answers

At last, here I found the solution.

I added jdk path org.gradle.java.home=C\:\\Program Files\\Java\\jdk1.8.0_144 to gradle.properties file and did a rebuild. It works now.

like image 64
Viswesvar Sekar Avatar answered Oct 13 '22 00:10

Viswesvar Sekar


ERROR: Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_121 contains a valid JDK installation

Copy tools.jar from C:\Program Files\Java\jdk1.8.0_121\lib to C:\Program Files\Java\jre1.8\lib.

It's resolved the problem now.

like image 102
Anup Singh Avatar answered Oct 12 '22 23:10

Anup Singh


Just had this happen to me.

Apparently Java's automatic updater installed and configured a new version of the JRE for me, while leaving the old JDK intact. So even though I did have a JDK, it didn't match the currently "active" JRE, which was causing the error.

Download a matching version of the JDK to the JRE you currently have installed, (In OP's case 151) That should do the trick.

like image 39
Marco Aurélio Avatar answered Oct 12 '22 23:10

Marco Aurélio