File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes how to invoke external program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to invoke external program" Watch "how to invoke external program" New topic

how to invoke external program

Waldle Cai
Ranch Hand

Joined: Aug 16, 2000
Posts: 34
hi all,
Is there any way that I can invoke an external program or shell command under unix? Thanks a lot.
Elisabeth Van
Ranch Hand

Joined: Feb 09, 2001
Posts: 42
Here's some code that I've used to run an executable and pass in command line arguments.

Runtime rt = Runtime.getRuntime();
Process prcs = rt.exec("/prd1/exe/udms mod 4rw salary gen con <infile.txt >/dev/null");

In this example, udms is the executable, the rest of it is command line arguments particular to this application. Hopefully this will help you get started. You're also going to have to handle IOException and InterruptedException.
Hope this helps.
Waldle Cai
Ranch Hand

Joined: Aug 16, 2000
Posts: 34
thanks for your prompt reply!! it's exactly what i wanted.
It is sorta covered in the JavaRanch Style Guide.
subject: how to invoke external program
Similar Threads
How to Have a command line in Eclipse ?
running executable jars
How to invoke an external program in java application?
Avoid to Upload a Virus...
Invoking an .exe from a JSP page.