1

I have to execute several command line executables in Windows through Java. Rather than using Runtime.exec, I thought of using Ant Tasks to do these invocations, hoping it would be a better way.

Is there any other better approach or any popular library to do this?

3 Answers 3

5

What exactly is wrong with using Runtime.exec()? It's in the API for a good reason...

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

Comments

1

Runtime.exec is the way of doing this in Java. Any other library would likely be platform specific. You'd need a very good reason not to use Runtime.exec.

I've currently got several programs that make use of this feature and it hasn't caused any trouble.

With Runtime.exec you can optionally block while waiting for the call to complete. You can capture return codes and anything the command line program writes to the console. And I'm sure there are many other features, those are just the ones that were useful to me.

And you can always have it invoke an ant task if you really want to use ant! :)

Comments

0

I have a similar situation now. I use Runtime and Process classes. They work just fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.