February 16th, 2004, 05:36 AM
Ant unable to locate tools.jar and setting environmental variables
Hi. I am having problems installing apache ant.
I installed ant at C:\apache-ant-1.6.1, and I have j2sdk at C:\j2sdk1.4.1_02.
I set JAVA_HOME as C:\j2sdk1.4.1_02 and ANT_HOME as C:\apache-ant-1.6.1. PATH is set with %JAVA_HOME%\bin; %ANT_HOME%\bin.
1) execute java commands (ie java, javac) at any directory.
1) execute ant cmd (ie ant -version) at any directory except ANT_HOME\bin.
2) and when I do, I get "Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\j2re1.4._02\lib\tools.jar."
There is no tools.jar in C:\Program Files\Java\j2re1.4._02\lib!
Also Tomcat was giving me this error "No Java compiler was found to compile the generated source for the JSP. This can usually be solved by copying manually JAVA_HOME/lib/tools.jar from the JDK to the common/lib directory of the Tomcat server, followed by a Tomcat restart. "
I followed the suggestion and bypassed that error, and I guess I can do the same with ant; but I want to figure out what I am doing wrong. >_<
PS. My note book came with an IBM 32-bit SDK for Java 2, v.1.4.1 that I did not uninstall.
April 13th, 2004, 07:24 AM
Take a look in C:\lib
(I copied it in the java jdk folder )
April 13th, 2004, 09:25 AM
"Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\j2re1.4._02\lib\tools.jar."
Assuming you didn't mis-type this error message, it looks like JAVA_HOME is trying to access a non-existent directory called "j2re1.4._02"
The fact that you can run ant from its bin directory but nowhere else suggests that there's something wrong with your PATH settings.
Go into DOS and type
and post what's in them.
Oh, and if you're using Win ME or Win 98 then you may have to shorten the names of your directories. And if you bought a notebook with Win ME on it, I have some magic beans to sell you
April 14th, 2004, 03:20 AM
Thanks for the reply. I almost forgot i post this question.
I'm getting the follow in DOS:
echo %JAVA_HOME% returns "C:\j2sdk1.4.1_02"
echo %ANT_HOME% returns "C:\apache-ant-1.6.1"
echo %PATH% returns "C:\j2sdk1.4.1_02\bin; C:\apache-ant-1.6.1\bin;...(and other unrelated paths)"
It seems that eventhing is setup correctly, but ant is still looking under C:\Program Files\Java\j2re1.4._02\lib for tool.jar.
My guess is that "C:\Program Files\Java\j2re1.4._02" is embedded somewhere in registry as factory default (since the notebook came with an IBM 32-bit SDK for Java 2, v.1.4.1).
I am using winXP by the way.
April 14th, 2004, 08:41 AM
If I go into DOS and set my JAVA_HOME to something that doesn't exist (set JAVA_HOME=c:\invaliddir) then I get the same message as you do. It looks like Ant does try a Window's-specific value when it has nothing better to do.
What's the output of these commands:
dir %JAVA_HOME% (make sure the listing that appears is actually your Java directory)
If both of those work, then I'd start hacking away at ant.bat. The first two times I installed Ant, I had to remove the commands that checked for the existence of my JAVA_HOME because they were screwy.
September 26th, 2004, 11:24 PM
Unable to install ANT
I am glad to find this forum after a hard search.
I am having problem installing ANT. I already look thru this forum and find a
solution that did not work for me.
I have followed all the instruction correctly. Just for you indication this are
the steps that taken to install ANT:-
1.downlaod the binary ANT
2.Unzip the apache-ant-1.6.2 folder
3.make a new folder in C:/ant
4.copy the apache-ant-1.6.2 lib and bin folder to my C:\ant
Setting Environment Path
5.I add in the C:\ant\bin in Path
6.add in new ANT_HOME
7.i typed ant in my Command Prompt and get the follwoing error
--> 'ant' in not recognized as an internal or external command, operable program
or batch file
Can anyone plz help me about this? Is my Windows XP got some problme or what?
Help about this problem is been provided in -
But it does help me, and I would like to comment something about this too.
The author kurious, use different name like when he ask to save the ant folder as
and latter when he sent the enviroment path he wrote like this
--> c:\ant-1.6.1 [which is not the same]
Thanks in advance for the help.
<< aMir >>
September 27th, 2004, 12:45 AM
Yeah, it looks like I made a mistake in the other thread. The two directories should be identical. The next time you decide to drag up an old thread, could you perhaps post in the one where I made the mistake? Thanks.
Originally Posted by mir_shajahan
Last edited by kurious; September 27th, 2004 at 01:13 PM.
September 27th, 2004, 09:16 AM
Thread necromancy is bad mmkay?
Off-topic necromancy is worse.
[QUOTE=kurious]"Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\j2re1.4._02\lib\tools.jar."
Assume Ant is installed in c:\ant\. The following sets up the environment:
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_13
I was facing the below issue while executing the ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
Buildfile: build.xml does not exist!
So that it was searching the tools.jar directory in the lib of the jre6 but the file was located into the the jdk directory.
To solve the issue what I did was set the the JAVA_HOME from the command line
By executing the below command :
C:\>set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_13
Then I checked the Java Version and it works
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
And then I checked the ant and it also worked
Buildfile: build.xml does not exist!
Even I have faced this problem couple of times.
When I set PATH using JAVA_HOME and ANT_HOME it did not work for me too.
When I directly set jdk bin and ant bin directories in PATH it worked for me.
Why did you reply to a post from 2004? lol
Originally Posted by StevenC
~ There are only 10 types of people in the world: Those who understand binary, and those who don't.
November 22nd, 2010, 11:48 AM
I fixed this by installing the jdk which have this file.
The jre dont have it.
It works nice.
This is the best solution, it worked thank you
Originally Posted by kurious
April 3rd, 2012, 08:32 AM
Regarding -- Unable to find tools.jar and it is expected to be in ....
Copy the tools.jar in the expected folder...
Then the 'ant' command will work fine