java调用cmd命令

Runtime run = Runtime.getRuntime();
Process process = null;
try{
process = run.exec("notepad"); // 执行cmd命令
process.waitFor();
} catch(Exception e) {
System.out.println("Error executing notepad.");
}
System.out.println("Notepad returned "+ process.exitValue());  


你可能感兴趣的:(java,cmd)