Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run ant in servlet

 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I run Ant scripts in servlet? How to do it?
Thanks.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the exec method to make a call to the ant command line tool
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim:
Tried that:
String cmd = "java -Dant.home=c:\\temp\\ant org.apache.tools.ant.Main";
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic