Running UNIX commands in your Java application

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

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:

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+.

Leave a reply:

Your email address will not be published.


*

Sliding Sidebar