简体   繁体   中英

How to run a xulrunner app from java code?

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"

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM