java – Gradle does not find tools.jar
java – Gradle does not find tools.jar
I had this problem when I was trying to run commands through CLI.
It was a problem with system looking at the JRE folder i.e.
D:Program FilesJavajre8bin
. If we look in there, there is no Tools.jar
, hence the error.
You need to find where the JDK
is, in my case: D:Program FilesJavajdk1.8.0_11
, and if you look in the lib
directory, you will see Tools.jar
.
What I did I created a new environment variable JAVA_HOME
:
And then you need to edit your PATH variable to include JAVA_HOME, i.e. %JAVA_HOME%/bin;
Re-open command prompt and should run.
Found it. System property java.home is not JAVA_HOME environment variable. JAVA_HOME points to the JDK, while java.home points to the JRE. See that page for more info.
Soo… My problem was that my startpoint was the jre folder (C:jdk1.6.0_26jre) and not the jdk folder (C:jdk1.6.0_26) as I thought(tools.jar is on the C:jdk1.6.0_26lib folder ). The compile line in dependencies.gradle should be:
compile files(${System.properties[java.home]}/../lib/tools.jar)
java – Gradle does not find tools.jar
I got the same error using Eclipse trying to execute a Gradle Task. Every time I run a command (i.e. war) the process threw an exception like:
Could not find tools.jar. Please check that C:Program FilesJavaJre8 is a valid JDK install.
I tried the solution listed in this post but none of them solved this issue. Here my solution :
- Go to the Gradle Task view
- Right Click on the task you want to execute
- Select Open Gradle Run Configuration
- In the tab Java Home select your local JDK repository then click OK
Run again, Enjoy!