Bug 32820 - Unable to locate tools.jar in JDK 1.5.0_01
Summary: Unable to locate tools.jar in JDK 1.5.0_01
Status: RESOLVED INVALID
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.6.2
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-23 07:23 UTC by Gili
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gili 2004-12-23 07:23:23 UTC
Hi,

When JDK 1.5.0_01 is installed, Ant 1.6.2 breaks. It complains:

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

But in reality this file does not exist. In JDK 1.5.0_01, tools.jar only exists
in C:\Program Files\Java\jdk1.5.0_01\lib\tools.jar

Please post a workaround until this is fixed in the next release of Ant.
Comment 1 Jan Mat 2004-12-23 07:58:09 UTC
Workaround is including that file by hand:

ant -lib C:\Program Files\Java\jdk1.5.0_01\lib\tools.jar


But I think your environment is net set correctly. Just a view into ant.bat:
- execute %HOME%\antrc_pre.bat
- check ANT_HOME
- check Java
  1) set _JAVACMD=%JAVACMD%
  2) use java.exe from JAVA_HOME\bin
  3) use java.exe from PATH
- start Ant
- execute %HOME%\antrc_post.bat

1) I think your JAVA_HOME points to the JRE and not to the JDK.
2) If you cant reset your JAVA_HOME you could try to reset it in the %HOME%
\antrc_pre.bat and restore it in %HOME%\antrc_post.bat
3) If that doesnt work you could include tools.jar in CLASSPATH (maybe set in 
the pre bat).


These are the first statements about "Workaround" and first thoughts. I havent 
verified that behaviour yet.
Comment 2 Gili 2004-12-23 08:15:20 UTC
Jan,

You are a life saver. Turns out my JAVA_HOME still pointed to jdk1.5.0 instead
of jdk1.5.0_01. I don't know why this caused Ant to look inside my JRE directory
instead of JDK (maybe it got the wrong key from the registry?!) but anyway
fixing this value fixed the problem.

I don't think that the JDK/JRE installer sets JAVA_HOME, so you guys should
really have this working if it is undefined. I tried undefining it and it keeps
on looking inside my JRE directory. Any idea why?

Thanks,
Gili
Comment 3 J.M. (Martijn) Kruithof 2004-12-24 09:34:19 UTC
JAVA_HOME is an environment variable both on windows flavours and unix flavours.

If no JAVA_HOME is set ant uses the location of the found java executable to
determine JAVA_HOME itself. In case the found java executable is from the JRE
and not the JDK then tools will not be found.

In case a wrong JAVA_HOME is provided which has been either set by you, or your
administrator (or by an installer of some other program) it will be happily
used, and not yield the desired effect.