java – Unable to locate tools.jar

java – Unable to locate tools.jar

Yes, youve downloaded and installed the Java Runtime Environment (JRE) instead of the Java Development Kit (JDK). The latter has the tools.jar, java.exe, javac.exe, etc.

In case this is still an issue for anyone, I have a bit of clarification on the previous answers. I was running into this same issue using ant with only a JDK installed. Although, the JDK installer gave me a directory structure like this:

 Directory of C:Program FilesJava

05/08/2012  09:43 AM    <DIR>          .
05/08/2012  09:43 AM    <DIR>          ..
05/08/2012  09:46 AM    <DIR>          jdk1.7.0_04
05/08/2012  09:19 AM    <DIR>          jre6
05/08/2012  09:44 AM    <DIR>          jre7
               0 File(s)              0 bytes

and when I ran ant, it complained about not finding tools.jar under the jre7 subdirectory. It wasnt until I set JAVA_HOME=C:Program FilesJavajdk1.7.0_04 that the error went away.

java – Unable to locate tools.jar

  1. Install the Java SDK.

  2. Add a System Environment Variable called JAVA_HOME with the value of JDK location.
    Go to Control PanelSystem and SecuritySystem. Advanced System Settings, Environment Variables, System Variables, New… Example:
    Variable Name:JAVA_HOME
    Variable Value: C:Program FilesJavajdk1.7.0_21

  3. Close/reopen your CMD window so that the new variable takes effect before attempting to re-run the ant command.

Leave a Reply

Your email address will not be published.