Hi All I am using Ant for the first time and it gives me an error ant is not recognized as an internal or external command or batch file I downloaded ant 1.6.0 bin in a directory in C called as ANT_HOME and extracted the files in subfolder apache-ant-1.6.0-bin into its subfolder apache-ant-1.6.0. This binary ditribution came with Apache Xerces 2 XML parser. According to the installation instructions, I added XML parser's jar files and ant.jar files in the classpath variable in win XP and also set the ANT_HOME, JAVA_HOME and added the path variable as shown. classpath: .;C:\ANT_HOME\apache-ant-1.6.0-bin\apache-ant-1.6.0\lib\ant.jar;C:\ANT_HOME\apache-ant-1.6.0-bin\apache-ant-1.6.0\lib\xercesImpl.jar;C:\ANT_HOME\apache-ant-1.6.0-bin\apache-ant-1.6.0\lib\xml-apis.jar; ANT_HOME: C:\ANT_HOME\apache-ant-1.6.0-bin\apache-ant-1.6.0 JAVA_HOME: C:\J2SDK1.4.2_01 Path: %PATH%;%ANT_HOME%\bin javac and java work from command line. What is wrong here? I know you have answered a similar question to another person in the same forum. But I am not able to get it when I did it like that either. Please help me thanks in advance vidu
When i tried to go into the bin directory and type ant, it gives me Build.xml file not found now. I don't have any Build.xml file in that directory. So that is ok. But I have to compile using ant in a different directory where the Build.xml file exists. Should I add that directory to the path variable or classpath variable. I know that I am asking a silly question. But I am just not able to find where that mistake is. Please help me! thanks Vidu
I did execute it from the directory where the Build.xml is. It again gives ant is not recognized as an internal or external command or batch file. When I try to run it from netbeans, it compiles, distributes and builds the application , but it gives error markers in the files. When the files are in the right packages, it gives invalid package declaration. I really need help here. thanks again vidu
Originally posted by vidu mayur: I did execute it from the directory where the Build.xml is. It again gives ant is not recognized as an internal or external command or batch file.
That means that your PATH environment variable is not set correctly. Before calling ant, type "set path" and see wether there really is the correct ant-bin directory set.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Path= %ANT_HOME%\bin; C:\Documents and Settings\User\.netbeans\3.5\trialprograms\fr\or\op\bin;;%ANT_HOME%\bin; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH The name of the directory from where I typed set path is this: C:\Documents and Settings\User\.netbeans\3.5\trialprograms\FR\or\op>set path I added bin at the end of the directory's name in the path value. Is it ok. Still I am getting the same error from this directory. Please let me know the mistake I am doing. thanks Vidu
You installed ANT in this directory? C:\ANT_HOME\apache-ant-1.6.0-bin\apache-ant-1.6.0 When you typed set from the command line what was the output for PATH, CLASSPATH and ANT_HOME. Do they match your actual directory names?
Hi Paul I deleted the ant1.6.0 bin distribution and downloaded ant nightly build files ant apache alpha1.6. I downloaded antbin into C:\ant directory when I typed set from the C:\ant\bin directory, this was shown C:\ant\bin>set ANT_HOME=C:\ant; classpath=.;C:\ant\lib\ant.jar;C:\ant\lib\xercesImpl.jar;C:\ant\lib\xml-apis.jar; HOMEPATH=\Documents and Settings\RAMESH JAVA_HOME=C:\J2sdk1.4.2_01; Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Documents and Settings\RAMESH\j2sdk1.4.2_01\BIN;C:\j2sdk1.4.2_01\BIN;C:\Documents and Settings\Ramesh\jbproject;C:\Programfiles\putty\path\to\putty\ directory;%ANT_HOME%\bin;%JAVA_HOME%\bin; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH I set the environment variables as shown: path %ANT_HOME%\bin;%JAVA_HOME%\bin JAVAHOME: C:\j2sdk1.4.2_01 classpath C:\ant\lib\ant.jar;C:\ant\lib\xercesImpl.jar;C:\ant\lib\xml-apis.jar ANT_HOME c:\ant When I run ant from C:\ant\bin, I get this error Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher Thanks for taking the time to look into it. Please tell me what I have to change in the classpath. Vidu
Hi Paul I changed the classpath so that it included the jar files ant-launcher.jar and optional.jar. I didn't get the NoClassDefError after that. I set the path manually to C:\ant\bin and tried ant in the directory where the build file was. It gives me this message C:\Documents and Settings\RAMESH\.netbeans\3.5\trialprograms\FR\or>ant Buildfile: build.xml init: [mkdir] Created dir: C:\Documents and Settings\RAMESH\.netbeans\3.5\trialprograms\FR\build compile: [javac] Compiling 56 source files to C:\Documents and Settings\RAMESH\.netbeans\3.5\trialprograms\FR\build BUILD FAILED C:\Documents and Settings\RAMESH\.netbeans\3.5\trialprograms\FR\or\build .xml:17: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK Total time: 5 seconds C:\Documents and Settings\RAMESH\.netbeans\3.5\trialprograms\FR\or> I even tried setting the JAVA_HOME manually to set JAVA_HOME=C:\j2sdk1.4.2_01\bin Is this how I set it manually? Please let me know. Thanks Vidu
Hi All sorry for the numerous messages. Once I added the C:\j2sdk1.4.2_01\lib\tools.jar to the classpath, it is working. I still have one more question. When I run ant in the directory, all my files are getting compiled and the application starts and runs fine too using the produced jar files. But I get error markers in the files when I open it in Netbeans and it says invalid package declaration. What will be the reason? Thanks Vidu