0
public static void main(String[] args)
{
    String command = "/usr/bin/xulrunner -app /home/user/myapp/app.ini";

    System.out.print(command);
     try {
        Runtime rt = Runtime.getRuntime();
        Process pr = rt.exec(command);

         BufferedReader input = new BufferedReader(
                new InputStreamReader(pr.getInputStream()));
        String line = null;
        while ((line = input.readLine()) != null) {
                System.out.println("\n"+line);
        }
        int exitVal = pr.waitFor();
        System.out.println("\nExited with error code " + exitVal);
    } catch (Exception e) {
        System.out.println(e.toString());
        e.printStackTrace();
    }
}

此代码打印:“退出并出现错误代码 2”

当我在终端中运行“/usr/bin/xulrunner -app /home/user/myapp/app.ini”时,它工作正常。它打印“Hello world”

4

1 回答 1

0

您启动 xulrunner 的代码似乎是正确的。您必须弄清楚为什么 xulrunner 返回 2 作为错误代码。

于 2010-10-08T14:15:11.377 回答