如何从 java 代码运行 xulrunner 应用程序?

发布于 2024-09-26 15:51:17 字数 843 浏览 0 评论 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”

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

This code prints:
"Exited with error code 2"

When I run "/usr/bin/xulrunner -app /home/user/myapp/app.ini" in Terminal it works ok.
It prints "Hello world"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反话 2024-10-03 15:51:17

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

It seems that your code to launch xulrunner is correct. You'll have to figure out why xulrunner is return 2 as an error code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文