1

这是我的代码,我不确定为什么会出现以下错误:

 Opening firefox at Sun Oct 28 21:45:27 EDT 2012
 java.io.IOException: Cannot run program "firefox.exe": CreateProcess error=2, The system cannot find the file specified

public static void open(String app) {
        try {
            Calendar calendar = Calendar.getInstance();
            Date now = calendar.getTime();
            System.out.println("Opening " + app + " at " + now);
            ProcessBuilder builder = new ProcessBuilder(app+".exe");
            builder.start();
        }
        catch (IOException e) {
            System.out.println(e);
        }
    }

有什么建议么?

4

1 回答 1

3

您必须指定 Firefox 可执行文件的完整路径。

于 2012-10-29T01:52:40.020 回答