Java Process Builder IO异常 - 不会运行程序

时间:2012-10-29 01:48:36

标签: java process processbuilder

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

 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);
        }
    }

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

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