tags:

views:

350

answers:

3

Hello everyone,

I am currently developing a "debugger" java application that uses JDI to connect to an already running "target" java application. Is there anyway to have ant launch my target application then launch my "debugger" afterwards while the first application is still running?

Yes I know that I can develop the JDI app to launch the target program, but that is not what I want right now.

Thank you!

+3  A: 

Look at the doc for Ant's <exec> directive - you should be able to add a call to the target application with <exec> that will amp off by using the "spawn" parameter.

Edit: sorry, "amp off" is slang for running a process in the background, which allows Ant to continue working while that process runs.

Arkaaito
I see, the only problem that I have with exec is that running java programs across OS is very different. I would need an exec for every os, no?
Sandro
+1  A: 

You can certainly spawn processes from ant. Here's a simple example:

<target name="sleeper">
    <exec executable="sleep" spawn="yes">
       <arg value="100" />
    </exec>
</target>

If you run this task* you'll see ant run to completion, but a ps will show the sleep persists.

The java task also supports spawn

*the example assumes a UNIX variant OS as it uses the sleep command.

martin clayton
Is there an OS independent solution?
Sandro
Using the java task with spawn is OS independent. If you want to spawn different executables then you are certainly heading into an OS specific world. But the exec task allows you to specify which OS's the task is ran for.. (run this only on windows, run this only on unix, etc)
Matt
+2  A: 

You can spawn two java programs from within an ANT parallel task.

<parallel>
  <sequential>
    <java fork="true" classname="prog1 .... >
  </sequential>
  <sequential>
    <sleep seconds="30"/>
    <java fork="true" classname="prog2.... >
  </sequential>
</parallel>

The sleep task in the second thread could be replace by a waitfor condition.

Mark O'Connor
Thank you! That is exactly what I was looking for!
Sandro