Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant + Vista 64 : "Unable to locate tools.jar" (jre/jdk conflict?)

I'm trying to use ant in a vista 64 environment to build some docbook/xml files.

However, I can't resolve this error message. Anybody have suggestions?

C:\Users\Robert Admin>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

Googling around, I see that this tools.jar message is the result of ant not being able to find the jdk. In fact, C:\Program Files\Java\jre6\li b\tools.jar is a JRE installed with another program (I'm guessing). Tools.jar is located here: C:\Program Files\Java\jdk1.6.0_22\lib

I can't seem to tell Ant to look in the JDK path, only the JRE path which was already there. (Judging from the Ant documentation, it seems that JRE is insufficient).

C:\Users\Robert Admin>echo %JAVA_HOME%

C:\Program Files\Java\jdk1.6.0_22\bin

C:\Users\Robert Admin>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

C:\Users\Robert Admin>echo %ANT_HOME%

I:\My Documents\1latest\ant    
C:\Users\Robert Admin>where java

C:\Windows\System32\java.exe
C:\Program Files (x86)\Java\jre6\bin\java.exe
C:\Program Files\Java\jdk1.6.0_22\bin\java.exe

C:\Users\Robert Admin>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

Update #1. I tried uninstalling the 64 bit jdk and installing the 32 bit jdk. Result:

C:\Users\Robert Admin>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

C:\Users\Robert Admin>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
C:\Users\Robert Admin>echo %JAVA_HOME%
C:\Program Files (x86)\Java\jdk1.6.0_22\bin
like image 497
idiotprogrammer Avatar asked Dec 07 '10 15:12

idiotprogrammer


1 Answers

I had the same problem because my JAVA_HOME path was set incorrectly (just like the OP's). It was set to the bin of the jdk.

So it was set to: C:\Program Files (x86)\Java\jdk1.6.0_25\bin

When it should have been set to: C:\Program Files (x86)\Java\jdk1.6.0_25

Updating this environmental variable fixed it for me.

like image 164
Gary Brunton Avatar answered Sep 30 '22 19:09

Gary Brunton