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

后端 未结 16 2185
天命终不由人
天命终不由人 2020-12-01 02:50

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:

相关标签:
16条回答
  • 2020-12-01 03:02

    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.

    0 讨论(0)
  • 2020-12-01 03:02

    My issue was two-fold:

    1. I had the JRE installed, but not the JDK.
    2. I did not have a JAVA_HOME environment variable set.

    Note: I am using Fedora Linux.

    To resolve the first issue, I followed these instructions

    To resolve the second, I merely added the following line to my ~/.bashrc file:

    export JAVA_HOME=/usr/lib/jvm/java/
    

    I had to restart my IDE and terminals to ensure the change to the ~/.bashrc took affect.

    0 讨论(0)
  • 2020-12-01 03:02

    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.

    0 讨论(0)
  • 2020-12-01 03:04

    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.

    0 讨论(0)
  • 2020-12-01 03:06

    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

    0 讨论(0)
  • 2020-12-01 03:08

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

    0 讨论(0)
提交回复
热议问题