Thanks for the reply. I'm still confused. In the command given by you "ant -f build.xml compile" compile is the target name in your ant file. I have build.xml at some location. If we do it manually we give the path of the build file in command prompt and type 'ant' and run the build.xml the same thing I want to do with java program. I mean to say my program won't depend upon the content of the build file.
Originally posted by bhaveshkumar chaudhari: I'm doing automation of testing. I have a build.xml(ant file) which in turn compiles the code. But the problem is how to execute the command so that file code will get compiled automatically.
According, to my understanding, what you want to do is:- 1) Want to Compile your java classes(source code) 2) Confused about what target to call for compilation of your code
Now, as you say that you already have build file named- build.xml, In your build file look for project tag which will be written as
In the above piece of code, in project tag, default target name is mentioned, so it will be called by default if you do not mention any target name with ant command.
if the build file name is build.xml, then no need to mention the build file name, so your command to execute the default target would be 'ant'.
And in default target above, the javac task is called, which does the compilation thing.