Hi, all.
I have a task that I have written that calls the main method of a java
class after doing some parameter munging. This main method does a
System.exit. I cannot easily rewrite that part of the code, so I need
to work around it.
I presume the "right way" is to just fork. I looked at the docs, and it
indicates that Java and ExecuteJava will handle this, but I kind of
foundered looking at the taskdef javadocs for Java and ExecuteJava.
Assuming I have a Task already written with a stack of instance
variables, getters, setters, and a working execute method that ends with
a call to the main class of the thing I am wrapping.
Can anyone point me to how I need to modify this to use the appropriate
fork code? What follows is my best attempt, but the call appears to not
have the same classpath as the task that spawned it.
public class AntIntercalateTask extends Task {
boolean _theParam=false
public void setTheParam(boolean theParam)
{
_theParam=setTheParam;
}
public AntIntercalateTask()
{
}
execute()
{
// worked, save for System.exit
//String[] args={"param1", "value1"};
//com.Foo.main(args);
// cannot find classpath
CommandlineJava cmdline = new CommandlineJava();
cmdline.createArgument().setValue("param1");
cmdline.createArgument().setValue("value1");
prepareArguments(cmdline);
cmdline.setClassname("com.Foo");
Execute exe=new Execute();
exe.setCommandline(cmdline.getCommandline());
try{
exe.execute();
} catch (Exception e){
System.out.println(e);
}
}
}
So, how can I transplant the classpath from the taskdef?
Scott
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>