运行文件
Process proc = Runtime.getRuntime().exec(“exefile”);# Windows
Process proc = Runtime.getRuntime().exec(“./exefile”);# Linux
运行命令行
String[] cmd = {“cmd”,“/C”,“copy exe1 exe2”};# Windows
Process proc = Runtime.getRuntime().exec(cmd);# Windows
String[] cmd = {“/bin/sh”,“-c”,“ln -s exe1 exe2”};# Linux
Process proc = Runtime.getRuntime().exec(cmd);# Linux
运行命令行并弹出命令行窗口
String[] cmd = {“cmd”,“/C”,“start copy exe1 exe2”};# Windows
Process proc = Runtime.getRuntime().exec(cmd);# Windows
String[] cmd = {“/bin/sh”,“-c”,“xterm -e ln -s exe1 exe2”};# Linux
Process proc = Runtime.getRuntime().exec(cmd);# Linux
设置调用程序的工作目录
Process proc = Runtime.getRuntime().exec(“exeflie”, null, new File(“workpath”));# Windows
Process proc = Runtime.getRuntime().exec(“./exeflie”, null, new File(“workpath”));# Linux