Could not find tools.jar. Please check that C:\Pro

2020-01-30 17:51发布

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

15条回答
欢心
2楼-- · 2020-01-30 18:17

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.

查看更多
叛逆
3楼-- · 2020-01-30 18:17

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

查看更多
别忘想泡老子
4楼-- · 2020-01-30 18:20

I had the same problem and fixed it like this:

  1. Install the JDK from the Oracle website with the same version number as the JRE if you didn't already.
  2. Furthermore add JAVA_HOME to the environment variables of Windows.
  3. Restart your terminal or development environment to load the new JAVA_HOME value.

JAVE_HOME in System Environment Variables

查看更多
淡お忘
5楼-- · 2020-01-30 18:22

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.

enter image description here

查看更多
▲ chillily
6楼-- · 2020-01-30 18:24

My error was solved by uninstalling all java updates and java from control panel and reinstalling JDK

查看更多
Explosion°爆炸
7楼-- · 2020-01-30 18:30

In Eclipse

Right click Project --> Java Build Path --> Libraries

  1. Remove the JRE
  2. Click on Add Library --> JRE System Library -->Next -->Alternate JRE --> installed JRE --> Add JDK and select and Apply
查看更多
登录 后发表回答