Você pode usar Runtime.exec()
. Aqui está um exemplo muito simples:
import java.io.*;
import java.util.*;
class Foo {
public static void main(String[] args) throws Exception {
// Run command and wait till it's done
Process p = Runtime.getRuntime().exec("ping -n 3 www.google.de");
p.waitFor();
// Grab output and print to display
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
}