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

JVM terminates when callling ant script from java

 
Abdul Mohsin
Ranch Hand
Posts: 111
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to run ant script from java code like this:
Launcher.main(new String[]{"-f","C:\\Projects\\ant_projects\\chap1\\Echo2.xml"});
System.out.println("*********** In End");

and able to successfully call the ant script but it looks that JVM is terminated after calling ant script as the logger "in End" is not printed in the console.

Is there any way to change this default behariour of ant to exit the JVM?

Please help.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the source code, Launcher.main calls System.exit if there is a non-zero exit code. You could try calling the run method instead, like this:

int code = new Launcher().run(new String[]{...});
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic