Ant is a batch file. Take a look, and you'll see a file called ant.bat
in the %ANT_HOME%\bin
directory.
Ant is actually a Java program, so you could launch it from the java command by running the class org.apache.tools.ant.launch.Launcher
which is basically what the ant.bat
file is doing.
However, why reinvent the wheel? The ant.bat
runs the Java command the right way, gives you options to change the way it's executed, and makes sure everything is setup correctly.
Addendum
I see, Nant, unlike Ant, will always call cmd.exe
and use suffixes and %PATHEXEC%
to figure out if something is a batch script or other type of script. Thus, if you want to run Ant using Ant as a batch script via <exec/>
you would do this:
<exec executable="cmd.exe"
dir="${working.dir}">
<arg value="/c"/>
<arg value="ant.bat"/>
</exec>
However, in Nant you can simply do it this way:
<exec program="ant"
workingdir=${working.dir}"/>