try{
String cmds="java -version";
Process p = Runtime.getRuntime().exec(cmds);
int exitValue = 1;
if((exitValue = p.waitFor()) != 0)
{
p.destroy();
System.out.println("exitValue:"+exitValue);
System.exit(exitValue);
}
}catch (IOException e) {
e.printStackTrace();
}catch (InterruptedException e) {
e.printStackTrace();
}
原文:http://blog.csdn.net/dvd423/article/details/29631191