public class TestCmd {
public TestCmd() {
}
public static void main(String args[]) {
try {
// 登网站
Process process = Runtime.getRuntime().exec(
"cmd.exe /c start
http://www.hao123.net/");
// 使用用Ping命令
Process ee = Runtime.getRuntime().exec(
"cmd.exe /c start ping 10.5.2.19");
} catch (Exception e) {
e.printStackTrace();
}
}
}
运行这个类你会看到效果