0

I have an Ant task that builds an executable JAR file, runs some JUnit tests, and then runs the executable JAR file to see if it was built correctly. However, the problem is that I have to be next to my computer to shut down my Java program. Is there a way to shut it down from Ant after it runs for maybe a few seconds?

<target name="buildAndTest" depends="create-submission-jar"> <!-- Other stuff happening here --> <java fork="true" jar="${jar.executable}" failonerror="true" /> </target> 
1

1 Answer 1

1

Likely your application is threaded and has a concept of a main loop. I think the easier approach is letting your app accepting an extra parameter like --timeout=120s, and using this parameter to make a Timer that gracefully ends the main loop (I think you'll have some sort of control variable, a PID file or anything). Then Ant will pass this extra parameter, so after some time the process end by itself.

Obviously, when the parameter is not set, the Timer is not created at all and you'll use your normal way to tell the program to stop.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.