我有这个代码:
import javax.swing.JOptionPane;
class OpenProgram {
public static void main(String[] args) throws Exception {
// opens the JOptionPane
String path = JOptionPane
.showInputDialog("Type the path to a program or other file(forward slashes)");
//runs the program
Process run = Runtime.getRuntime().exec("\"" + path);
System.out.println("Program Opened!");
run.waitFor();
}
}
它应该调出一个 JOptionPane 并让用户输入程序的路径,然后运行指定的程序,但是当我测试它并在 JOptionPane 上按 OK 时,它说它无法运行它。有什么帮助吗?