Running UNIX commands in your Java application

by Alvin Poh | Tue, Jul 3, 2007

Miscellaneous, Programming & Code


I was looking around for a method to run commands from the prompt automatically from within my Java application, and then I found it. Here’s the solution – and it works like a charm!

static void doExec1() throws IOException {

// use pipes and I/O redirection
// but without using a shell

Runtime runtime = Runtime.getRuntime();
runtime.exec(“ls | wc >out1″);
}

Similar Posts:

Tags: , ,

This post was written by:

- Alvin Poh lives in Singapore, and is interested in marketing, techy stuff, and likes to just figure out how the two can work with each other. He can also be found on Google+.

Get Alvin's Report On How To Blog Successfully - Free!

Leave a Reply

*