Вот так:
Код:
class Mon
{
public Mon()
{
}
public synchronized void Run(String cmd, int i)
{
try
{
Runtime runtime = Runtime.getRuntime();
Process p = null;
String nStream = " Stream (" + i + ") Run: [" + cmd + "]...";
System.out.print(nStream);
p = runtime.exec(cmd);
if (p.waitFor() == 0)
{
System.out.print(" ok");
}
else System.out.print(" error");
}
catch (Exception e) { e.printStackTrace(); }
}
}