ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Solofnenko <>
Subject RE: Integrating Ant into another tool - How do I get around Syste m.exit(0) call in Main.start()?
Date Tue, 07 May 2002 00:35:43 GMT

  this is what I did to disable System.exit() in my test application:

 // just to keep track of return codes. You can use SecurityException itself
  public class ExitException extends SecurityException {
    public int rc; 
    ExitException(int rc) {

  public static void main(String[] args) throws Throwable {
    SecurityManager oldManager=System.getSecurityManager();
    System.setSecurityManager(new SecurityManager() {
      public void checkExit(int status) { throw new ExitException(status);}
      public void checkPermission(Permission perm, Object context) {}
      public void checkPermission(Permission perm) {}
    int rc=0;
    try {
    catch (ExitException ex) {
       if (ex.rc!=0) rc=ex.rc;
    try {
    catch (ExitException ex) {
       if (ex.rc!=0) rc=ex.rc;
    }    System.setSecurityManager(oldManager);

  Alexey Solofnenko.

{   } Alexey N. Solofnenko
{ } Inventigo LLC
Pleasant Hill, CA (GMT-8 usually)

-----Original Message-----
From: Mark Reid []
Sent: Monday, May 06, 2002 5:28 PM
To: Ant Developers List
Subject: Integrating Ant into another tool - How do I get around
System.exit(0) call in Main.start()?


I'm currently writing a web front end for building a product and would like
to integrate Ant into it. Everything was going along fine until I tried
calling the Main.start(...) method from inside a .jsp. When completed,
Main.start(...) calls System.exit(0), taking down Tomcat with it.

I've found references to this problem on the web
( so it
looks like it's been discussed here before. That post quotes the docs

    * If you integrating Ant into some other tool, this is not the class
     * to use as an entry point. Please see the source code of this
     * class to see how it manipulates the Ant project classes.

This is what I'm doing at the moment but to save me some painful mistakes I
was wondering if anyone has done this before and would be willing to give me
some tips. It's important that I be able to hook up a listener to the
project being run.

Thanks in advance,

Mark Reid

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

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

View raw message