ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Drew Davidson <>
Subject Re: invoking ant from jsp on win2k
Date Fri, 13 Sep 2002 14:36:46 GMT
Stefan Lipp wrote:

>yes: ant.bat or %ANT_HOME%\bin is in the system path.
>>please accept my apologies if i'm restating prior solutions or
>>suggestions; i haven't been following the mailing list for a couple of
>>can ant.bat be found on the Path?
>>i've ran into similar errors when ever my 'User Variables' weren't
>>/realized/.  meaning, they weren't filled in or updated.  try updating
>>the Path that is in 'System Variables' by adding %ANT_HOME%\bin.
>>again, if this has been suggested before, accept my apologies.
>>mel riffe
>>-----Original Message-----
>>From: Stefan Lipp []
>>Sent: Friday, September 13, 2002 10:08 AM
>>Subject: invoking ant from jsp on win2k
>>sorry for another post, but all previous solutions mentioned didn't
>>My case plain spoken:
>>Used API in jsp and tried to fire up ant with given path to build-file
>>which works all in a dos-box:
>><%@ page import=""%>
>><%@ page import=""%>
>><%@ page import=""%>
>>   Project project = new Project();
>>   ExecTask exec = new ExecTask();
>>   exec.setProject(project);
>>   exec.setExecutable("ant.bat");
>>   Commandline.Argument arg = exec.createArg();
>>   arg.setLine("-buildfile
>>   e:/jakarta-tomcat-3.2.3/webapps/vignette_dev/build.xml");
>>tomcat error:
>>javax.servlet.ServletException: Execute failed:
>>CreateProcess: ant.bat -buildfile
>>e:/jakarta-tomcat-3.2.3/webapps/vignette_dev/build.xml error=2
>>What went wrong? Is it that windows? Does sombody has a

I think the problem here is that the syntax you are using is acceptable 
from a shell - i.e. type "ant.bat ..." and it will execute ant.bat as a 
script under Windows.  When you are using exec() (or CreateProcess() 
under Windows) directly you have no such convenience.  Therefore you 
must start the script using the executable shell with the ant.bat as a 

$ cmd.exe /c C:\jakarta\ant-1.4.1\bin\ant.bat

Two problems here:
1) Although cmd.exe will be in your path (probably since it's in 
/WINNT/system32), you must have the absolute path to the bat file to 
pass to the command interpreter.  If you have Cygnus utils or some such 
installed you can do "which ant.bat" to retrieve the absolute path, else 
you are stuck with putting the location into a properties file and 
requiring that it be changed for each installation.
2) The command interpreter to execute varies on NT and [95, 98, ME and 
derivatives].  NT has cmd.exe and [95 et. al.] have  If you 
are only using NT, 2000, XP then you can assume cmd.exe (which I do when 
doing this sort of stuff).

The other option is to call Ant directly using the API and forego the 
exec()...or is this not an option?

- Drew

< Drew Davidson | OGNL Technology >
|  Email:          /
|    Web:   /
|    Vox: (520) 531-1966       <
|    Fax: (520) 531-1965        \
| Mobile: (520) 405-2967         \

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message