如何从 java 代码运行 xulrunner 应用程序?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您启动 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.