开发者

Can Ant launch two java applications concurrently?

开发者 https://www.devze.com 2022-12-18 15:15 出处:网络
I am currently developing a \"debugger\" java application that uses JDI to connect to an already running \"target\" java application. Is there any way to have Ant launch my target application then lau

I am currently developing a "debugger" java application that uses JDI to connect to an already running "target" java application. Is there any way to have Ant launch my target application then launch my "debugger" afterwards, wh开发者_JS百科ile 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.


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.


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*.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号