File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Runtime exec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Runtime exec" Watch "Runtime exec" New topic

Runtime exec

Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
I have to execute a command line many times when some event is triggered. For this Ive been using Runtime.exec() for executing each command line. This seems to take up a lot of memory. Is there a better way to do it?

Thanks<br />Karthik<br />SCJP 1.4, CCNA.<br /> <br />"Success is relative. More the success, more the relatives."
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

"Karthik" -
Please review our site's naming policy at your earliest convenience. We prefer that all screen names follow this convention. Thank you.
There are other ways to accomplish what you want, but none of them are nearly so simple as what you're doing now. For more efficient use of resources, you'll probably need to create a program that can thread your command-line invocations within a single process space.
It's also possible that what you're invoking might be easily rewritten to be more efficient.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
Thanks. And sorry about the name, I've changed it to my full name.
I agree. Here's the link:
subject: Runtime exec
It's not a secret anymore!