• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ant problem

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have the same problem for both Ant 1.6.2 and 1.6.3, hope someone can help me out. I
1) downloaded the ant zip file (binary distributions)
2) unzipped it to "c:\ant"
3) cd to "c:\ant\bin"
4) type "ant -version"

I got error message below:
Buildfile: build.xml does not exist!
Build failed

It seems the command line just don't want to take any argument after "ant". Non matter what argument that I put after the "ant" (eg, "ant -help", "ant -diagnostics"), it always displays "Buildfile: build.xml does not exist!". If I put the build.xml on "c:\ant\bin", it runs just fine... Anyone can help??

The OS of my machine is Win2k with service pack 4. thanks.
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Is it possible that you did not specify the '-' before the keyword


when you launch ant, it will look for your build script (build.xml by default) where you define your build strategy : clean, compile,test, createJar, javadoc...

First, you should define your environment variables to point to ant, and while you're at it, java, path and classpath :

SET ANT_HOME=utils\ant
SET JAVA_HOME=utils\jdk1.4.2
SET PATH=%JAVA_HOME%\bin;%ANT_HOME%\BIN;%PATH%
SET CLASSPATH=%JAVA_HOME%\lib;.;%CLASSPATH%

Now you can launch ant from wherever you are by typing "ant compile".
Typing this will go through the build.xml you wrote and execute the target "compile". Your build.xml should be in the current directory when you launch ant.

If you want, you can specify another filename for your buildscript :

Hope this helps,
Alex
[ May 05, 2005: Message edited by: Alex Turcot ]
 
dave chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

First of all thanks for reply.
Actually, I already set all the system path as well as JAVA_HOME/ANT_HOME. I ran the "echo" command and confirmed they were corrected.

I am sure I include the "-" with the command "ant -version" that I typed. As I state, it just ignores the second argument that I type on the command line. It doesn't matter if I type "ant -version" or "ant -help", it always return the error message "Buildfile: build.xml does not exist!". If I create a sample "build.xml", everything run just fine.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your you don't have an "ANT.BAT" file in your path covering up the %ANT_HOME$\bin\ant program? I had no problems with Ant 1.5 or 1.6.2.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I'm not sure what you've done. Your original steps are not what the Ant manual - installation instructions say to do. Since you insist everything is correct and don't show us the output how are we to help? We can point to instructions and troubleshooting information.

From Ant "Having Problems" page:

Also, we highly recommend that you run Ant with an empty CLASSPATH. If any other version of Ant can be loaded from the CLASSPATH, many types of errors may happen because of incompatible classes being loaded.

See the FAQ for some examples, but many other problems are a result of an old version of Ant on your system as well.
 
dave chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I comment out the first line of the ant.bat and dump the result of the command "ant -version" as below. I really don't know what happen here. I try to install ANT on my friend's pc and everything's cool. Any suggestion?


=============================================================
C:\temp>REM @echo off

C:\temp>REM Copyright 2001,2004-2005 The Apache Software Foundation

C:\temp>REM

C:\temp>REM Licensed under the Apache License, Version 2.0 (the "License");

C:\temp>REM you may not use this file except in compliance with the License.

C:\temp>REM You may obtain a copy of the License at

C:\temp>REM

C:\temp>REM http://www.apache.org/licenses/LICENSE-2.0

C:\temp>REM

C:\temp>REM Unless required by applicable law or agreed to in writing, software

C:\temp>REM distributed under the License is distributed on an "AS IS" BASIS,

C:\temp>REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

C:\temp>REM See the License for the specific language governing permissions and

C:\temp>REM limitations under the License.

C:\temp>if exist "\antrc_pre.bat" call "\antrc_pre.bat"

C:\temp>if "Windows_NT" == "Windows_NT"

C:\temp>if "Windows_NT" == "WINNT"

C:\temp>rem C:\ANT\bin\ is expanded pathname of the current script under NT

C:\temp>set DEFAULT_ANT_HOME=C:\ANT\bin\..

C:\temp>if "C:\ANT" == "" set ANT_HOME=C:\ANT\bin\..

C:\temp>set DEFAULT_ANT_HOME=

C:\temp>set _USE_CLASSPATH=yes

C:\temp>rem Slurp the command line arguments. This loop allows for an unlimited number

C:\temp>rem of arguments (up to the command line limit, anyway).

C:\temp>set ANT_CMD_LINE_ARGS=-version

C:\temp>if ""-version"" == """" goto doneStart

C:\temp>shift

C:\temp>if """" == """" goto doneStart

C:\temp>rem find ANT_HOME if it does not exist due to either an invalid value passed

C:\temp>rem by the user or the -version problem on Windows 9x

C:\temp>if exist "C:\ANT\lib\ant.jar" goto checkJava

C:\temp>set _JAVACMD=

C:\temp>if "C:\Program Files\Java\jdk1.5.0_03" == "" goto noJavaHome

C:\temp>if not exist "C:\Program Files\Java\jdk1.5.0_03\bin\java.exe" goto noJavaHome

C:\temp>if "" == "" set _JAVACMD=C:\Program Files\Java\jdk1.5.0_03\bin\java.exe

C:\temp>goto checkJikes

C:\temp>if not "" == "" goto runAntWithJikes

C:\temp>if "yes" == "no" goto runAntNoClasspath

C:\temp>if not "C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGCLIENT.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGSERVER.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CICSJ2EE.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGSAMPLES.JAR;C:\Program Files\IBM\WebSphere MQ\Java\lib\providerutil.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\ldap.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jta.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jndi.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\connector.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\fscontext.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar;C:\oracle\ora90\jdbc\lib\ojdbc14.jar;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.jar;.;C:\PROGRA~1\IBM\SQLLIB\java\" == "" goto runAntWithClasspath

C:\temp>"C:\Program Files\Java\jdk1.5.0_03\bin\java.exe" -classpath "C:\ANT\lib\ant-launcher.jar" "-Dant.home=C:\ANT" org.apache.tools.ant.launch.Launcher -cp "C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGCLIENT.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGSERVER.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CICSJ2EE.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGSAMPLES.JAR;C:\Program Files\IBM\WebSphere MQ\Java\lib\providerutil.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\ldap.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jta.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jndi.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\connector.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\fscontext.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar;C:\oracle\ora90\jdbc\lib\ojdbc14.jar;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.jar;.;C:\PROGRA~1\IBM\SQLLIB\java\" -version
Buildfile: build.xml does not exist!

C:\temp>goto end

C:\temp>set _JAVACMD=

C:\temp>set ANT_CMD_LINE_ARGS=

C:\temp>if "Windows_NT" == "Windows_NT"

C:\temp>if "Windows_NT" == "WINNT"

C:\temp>if exist "\antrc_post.bat" call "\antrc_post.bat"

====================================================================
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try unsetting your classpath before running ant -version?

set classpath=

If with 1.6.3 I set my classpath to what is shown in your post I get your error of "build.xml does not exist!":


C:\_tools\apache-ant-1.6.3\bin>"c:\bea813\jdk142_04\bin\java.exe" -classpath "C:\_tools\apache-ant-1.6.3\lib\ant-launcher.jar" "-Dant.
home=C:\_tools\apache-ant-1.6.3" org.apache.tools.ant.launch.Launcher -cp "C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\C
TGCLIENT.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGSERVER.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\
Classes\CICSJ2EE.JAR;C:\Program Files\IBM\IBM CICS Transaction Gateway\Classes\CTGSAMPLES.JAR;C:\Program Files\IBM\WebSphere MQ\Java\li
b\providerutil.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\ldap.jar;C:\
Program Files\IBM\WebSphere MQ\Java\lib\jta.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jndi.jar;C:\Program Files\IBM\WebSphere MQ\J
ava\lib\jms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\connector.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\fscontext.jar;C:\Pr
ogram Files\IBM\WebSphere MQ\Java\lib\com.ibm.mq.jar;C:\oracle\ora90\jdbc\lib\ojdbc14.jar;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PR
OGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.jar;.;C:\PROGRA
~1\IBM\SQLLIB\java\" -version
Buildfile: build.xml does not exist!
Build failed
 
dave chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your suggestion.
It seems the string/value of the classpath is too long on my machine. I remove some of the value and then add "%JAVA_HOME%\bin" to the classpath, it runs fine now.
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a variety of things that can go wrong with ant when your classpath is set in your environment. I unset mine with 1.6.x and set up the necessary classpaths in the build.xml. Assuming you were going to have your classpath set you shouldn't need %JAVA_HOME%\bin included, that's not a place where classes live.

Ant "Having Problems" page:

Also, we highly recommend that you run Ant with an empty CLASSPATH. If any other version of Ant can be loaded from the CLASSPATH, many types of errors may happen because of incompatible classes being loaded.
 
dave chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so what should I do with my classpath?

I remove the "%JAVA_HOME\bin" and run the command "ant -version", it complains the missing of the "build.xml" file. I, however, run the command "ant -version -noclasspath", it displays the ant version information correctly. thanks.
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can specify your classpath in your build.xml.

See Path-like structures in the ant manual's Writing a simple build file.

Scroll down to the bottom of that page, to the references section to see example use of a "named" classpath in the javac task.
[ May 16, 2005: Message edited by: Carol Enderlin ]
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave Chan
Here is an example for set your classpath

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic