/** * java执行cmd命令,使用某程序打开某路径下的文件 */ class ExecDemo { public static void main(String args[]) { Runtime r = Runtime.getRuntime(); Process p = null; String cmd[] = { "notepad", "C:/123.txt" }; try { p = r.exec(cmd); } catch (Exception e) { System.out.println("error executing " + cmd[0]); } } }