Tom
Tom

Reputation: 363

DefaultExecutor not to wait for result (asynchronous call)

Is there a way to tell Apache DefaultExecutor not to wait for result and go on with code? Currently, it waits for a called program or script to terminate.

Upvotes: 0

Views: 885

Answers (1)

Fildor
Fildor

Reputation: 16128

The DefaultExecutor has methods for asynchronous execution.

without environment :

public void execute(CommandLine command, ExecuteResultHandler handler) 
                                               throws ExecuteException, IOException

and

with environment argument

public void execute(CommandLine command, Map<String,String> environment, ExecuteResultHandler handler)
         throws ExecuteException, IOException

If you want to ignore the results, you can pass a no-op implementation of the ExecuteResultHandler.

Upvotes: 1

Related Questions