Unable to locate tools.jar

136,033

Solution 1

A JRE doesn't have a tools.jar, you need a JDK. Set your JAVA_HOME and PATH variables so that they point to a JDK, not a JRE.

Solution 2

I had similar issue and got solved by doing following ,

1) set JAVA_HOME as C:\Program Files (x86)\Java\jdk1.7.0\

2) ANT_HOME as F:\ant\apache-ant-1.8.4-bin\apache-ant-1.8.4

3) add both to 'path ' in system variables

Solution 3

Please make sure that you are pointing to JDK and not a JRE. For example, you should set JAVA_HOME as "C:\Program Files\java\jdk1.6.0_26" and have %JAVA_HOME%\bin in your system path.

Solution 4

I had to copy C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar to C:\Program Files\Java\jre6\lib\ext

Thanks anyway.

Solution 5

tools.jar comes with JDK, but what happens in your case it looks for it within /Java/jre6. Change JAVA_HOME env var to one of your JDK home.

Share:
136,033
Wassim AZIRAR
Author by

Wassim AZIRAR

https://www.malt.fr/profile/wassimazirar I am not looking for permanent contract (no need to contact me for that) I develop 💻 in .NET Core, JavaScript, Angular and React ⚛

Updated on October 12, 2020

Comments

  • Wassim AZIRAR
    Wassim AZIRAR over 3 years

    Possible Duplicate:
    Unable to locate tools.jar

    I'm trying to use ant to compile using this command :

     ant compile
    

    I don't know if the problem comes from my windows 64bit, or by something else. Because I have java Installed in the 64 & 32 prog files.

    Java 64 & 32

    I downloaded apache-ant-1.8.2-bin and putted it in C:\Program Files\apache-ant-1.8.2

    I tried to put ant everywhere, I switched also the ENV PATH between java 64 and 32 but everytime I get this error message :

    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar

    I searched for tools.jar in the ant lib folder, in the java 64 and 32, but no trace of it in the system.

    What do you think ?

  • Sean Patrick Floyd
    Sean Patrick Floyd almost 13 years
    You should not do such a thing. A JRE is a JRE and a JDK is a JDK. Don't mix the two, or you'll get strange, non-reproducible behaviour
  • Wassim AZIRAR
    Wassim AZIRAR almost 13 years
    I have the jdk and jre in my %PATH%. you think I should remove the jre ?
  • Art Licis
    Art Licis almost 13 years
    I would even suggest removing all of Java installs on your dev machine except for single JDK you will be using :) Unless some of existing product installs don't depend on existing JREs.
  • basickarl
    basickarl over 10 years
    Caution: IN SOME CASES YOU MUST REMOVE THE JRE PATH FOR IT TO WORK.
  • Munchies
    Munchies over 9 years
    Adding "C:\Program Files\Java\jdk1.7.0_65" to JAVA_HOME and "C:\Program Files\Java\jdk1.7.0_65\bin" to PATH did the trick. (jdk1.7.0_65 is for JDK 1.7 Update 65 and can vary)
  • Sean Patrick Floyd
    Sean Patrick Floyd over 9 years
    @Munchies actually, it's more elegant to add %JAVA_HOME%/bin to path. that way you need to change only one variable when you upgrade
  • Christian
    Christian over 9 years
    Is there a reason why 1) ends with "\" and 2) doesn't?
  • Silvan Mudbind
    Silvan Mudbind over 9 years
    on Windows try restarting your computer, worked for me after.
  • John
    John over 9 years
    Is Windows the only OS where restarting means you lose your currently open Windows? I just restart the cmd console until I see changes propagated there. Unless of course you've elected to be elegant and some rogue script is overriding your JAVA_HOME path so that it's still pointing at the JRE
  • JavaTec
    JavaTec about 8 years
    For me, adding JAVA_HOME in the windows classpath/path did not help - rather i had to create a new environment variable - JAVA_HOME within the eclipse and point it to JDK7 - that worked
  • escalator
    escalator about 7 years
    In my case the variable CLASSPATH pointing to %JAVA_HOME%\jre\lib was missing, see stackoverflow.com/a/26640589/2518971