File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Running Ant from a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Running Ant from a Servlet" Watch "Running Ant from a Servlet" New topic
Author

Running Ant from a Servlet

Danish Shaukat
Ranch Hand

Joined: Nov 16, 1999
Posts: 340
Hi !
Any idea how I will run Ant from a servlet.
Basically I want to build an application when the servlet receives a request.
Danish
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
Hi Danish
I guess you are looking for Runtime.exec() functionality...basically you would do something like,
Runtime r = Runtime.getRuntime();
r.exec(new String[]{"/usr/bin/ant","<<your target>>"});
Note that I am using the String[] argument method as that is the good way I guess to invoke commands as the String argument method causes confusions sometimes and doesn't do what we want..I always go with String[] method..
google more for how to use exec() from java...
Regards
Maulin
Akbar Basha R
Greenhorn

Joined: Mar 11, 2002
Posts: 23
Hi
There is a class called "Project" under org.apache.tools.ant package available along with ant libraries.
you will be able to create a project and assign the build xml file for a specific build, using "Project" class.
The following methods in Project class can be used to create a project.
init();
setUserProperty("ant.file", buildfile);
executeTarget(target);
Project can be configured using "ProjectHelper" available in the same package. After creating and configuring a project, start the build, using "executeTarget" method.
-Akbar
SCJP
SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running Ant from a Servlet