The moose likes Servlets and the fly likes Run ant in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Run ant in servlet" Watch "Run ant in servlet" New topic

Run ant in servlet

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 672
Can I run Ant scripts in servlet? How to do it?

We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
use the exec method to make a call to the ant command line tool

Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 672
Thanks Tim:
Tried that:
String cmd = "java -Dant.home=c:\\temp\\ant";
Runtime rt = Runtime.getRuntime();

try {
Process pr = rt.exec(cmd);
Got this:
java.lang.NoClassDefFoundError: org/apache/tools/ant/Main
ant jar is in WEB-INF/lib too.
I agree. Here's the link:
subject: Run ant in servlet
It's not a secret anymore!