Unable to locate tools.jar [duplicate]
Asked Answered
J

5

77

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 ?

Junie answered 13/7, 2011 at 8:26 Comment(0)
P
156

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.

Pitiful answered 13/7, 2011 at 8:30 Comment(5)
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)Abe
@Abe actually, it's more elegant to add %JAVA_HOME%/bin to path. that way you need to change only one variable when you upgradePitiful
on Windows try restarting your computer, worked for me after.Yoshida
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 JREPisciform
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 workedMacrocosm
S
20

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

Savagism answered 1/11, 2012 at 12:49 Comment(1)
Is there a reason why 1) ends with "\" and 2) doesn't?Koy
A
4

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.

Aparejo answered 13/7, 2011 at 8:30 Comment(1)
In my case the variable CLASSPATH pointing to %JAVA_HOME%\jre\lib was missing, see https://mcmap.net/q/46645/-how-to-set-the-environment-variables-for-java-in-windowsAcquisitive
J
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.

Junie answered 13/7, 2011 at 8:31 Comment(4)
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 behaviourPitiful
I have the jdk and jre in my %PATH%. you think I should remove the jre ?Junie
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.Playback
Caution: IN SOME CASES YOU MUST REMOVE THE JRE PATH FOR IT TO WORK.Photoreconnaissance
P
3

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.

Playback answered 13/7, 2011 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.