如何从Java执行其他应用程序?
以下程序允许您使用Runtime.exec()方法从Java运行/执行其他应用程序。
package org.nhooo.example.lang;
import java.io.IOException;
public class RuntimeExec {
public static void main(String[] args) {
//String command = "/Applications/Safari.app/Contents/MacOS/Safari";
String command = "explorer.exe";
try {
Process process = Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
}