#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    6
    Rep Power
    0

    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.

    I can:
    1) execute java commands (ie java, javac) at any directory.

    I cannot:
    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. >_<

    Please advice.

    PS. My note book came with an IBM 32-bit SDK for Java 2, v.1.4.1 that I did not uninstall.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    1
    Rep Power
    0
    Take a look in C:\lib
    (I copied it in the java jdk folder )
  4. #3
  5. Prom night: 1973
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Dec 2001
    Posts
    1,156
    Rep Power
    24
    "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

    echo %JAVA_HOME%
    echo %ANT_HOME%
    echo %PATH%

    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
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    6
    Rep Power
    0
    Hi,
    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.
  8. #5
  9. Prom night: 1973
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Dec 2001
    Posts
    1,156
    Rep Power
    24
    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
    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:

    java -version
    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.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    9
    Rep Power
    0

    Unable to install ANT


    Hello everyone...

    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


    -->D:\oracle\ora92\jdk\jre\bin\classic;D:\oracle\ora92\jdk\jre\bin;D:\oracle\ora9

    2\bin;D:\oracle\ora92\jlib;C:\j2sdk1.4.2_05\bin;C:\oracle\ora92\bin;C:\Program

    Files\Oracle\jre\1.3.1\bin;C:\Program

    Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System

    32\Wbem;C:\ant\bin

    6.add in new ANT_HOME

    -->C:\ant

    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 -

    http://forums.devshed.com/t157310/s.html&highlight=ant
    http://forums.devshed.com/t122244/s.html&highlight=ant

    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
    --> c:\apache-ant-1.6.1

    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 >>
  12. #7
  13. Prom night: 1973
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Dec 2001
    Posts
    1,156
    Rep Power
    24

    Typo. Rats.


    Originally Posted by mir_shajahan
    The author kurious, use different name like when he ask to save the ant folder as
    --> c:\apache-ant-1.6.1

    and latter when he sent the enviroment path he wrote like this
    --> c:\ant-1.6.1 [which is not the same]
    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.
    Last edited by kurious; September 27th, 2004 at 02:13 PM.
  14. #8
  15. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    Thread necromancy is bad mmkay?
    Off-topic necromancy is worse.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Posts
    1
    Rep Power
    0
    [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 ANT_HOME=c:\ant
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_13
    set PATH=%PATH%;%ANT_HOME%\bin


    I was facing the below issue while executing the ant

    C:\>ant
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
    b\tools.jar
    Buildfile: build.xml does not exist!
    Build failed


    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

    C:\>java -version
    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

    C:\>ant
    Buildfile: build.xml does not exist!
    Build failed
    C:\>
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    485
    Rep Power
    103
    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.
  20. #11
  21. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Location
    Netherlands
    Posts
    115
    Rep Power
    292
    Why did you reply to a post from 2004? lol

    Originally Posted by StevenC
    Thread necromancy is bad mmkay?
    Off-topic necromancy is worse.
    ~ There are only 10 types of people in the world: Those who understand binary, and those who don't.
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0
    Hi,

    I fixed this by installing the jdk which have this file.
    The jre dont have it.

    It works nice.

    Cheers
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    Post


    [QUOTE=mohitsharma911]
    Originally Posted by 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 ANT_HOME=c:\ant
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_13
    set PATH=%PATH%;%ANT_HOME%\bin


    I was facing the below issue while executing the ant

    C:\>ant
    Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
    b\tools.jar
    Buildfile: build.xml does not exist!
    Build failed


    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

    C:\>java -version
    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

    C:\>ant
    Buildfile: build.xml does not exist!
    Build failed
    C:\>
    This is the best solution, it worked thank you
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    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

Similar Threads

  1. Problem setting mysql variables
    By SoLaRiZe in forum MySQL Help
    Replies: 1
    Last Post: August 19th, 2004, 06:12 PM
  2. Looping through an array and setting variables
    By bamaster in forum PHP Development
    Replies: 4
    Last Post: September 30th, 2003, 02:19 PM
  3. Replies: 3
    Last Post: September 23rd, 2003, 04:36 PM
  4. Replies: 0
    Last Post: August 20th, 2003, 11:52 AM
  5. setting and recognizing variables internally
    By bakedbean in forum Flash Help
    Replies: 13
    Last Post: March 30th, 2003, 11:39 PM

IMN logo majestic logo threadwatch logo seochat tools logo