题
我有一个用Java编写的应用程序.它被设计为独立运行在Linux机器上.我正在尝试生成一个新的firefox窗口.但是,Firefox从未打开过.它总是有一个shell退出代码1.我可以使用gnome-terminal运行相同的代码,它打开正常.
背景
所以,这是它的初始化过程:
一旦程序运行起来,用户可以点击一个按钮来生成一个firefox窗口.这是我的代码.记得X在显示器上运行:1.
码
public boolean openBrowser()
{
try {
Process oProc = Runtime.getRuntime().exec( "/usr/bin/firefox --display=:1" );
int bExit = oProc.waitFor(); // This is always 1 for some reason
return true;
} catch ( Exception e ) {
oLogger.log( Level.WARNING, "Open Browser", e );
return false;
}
}
Run Code Online (Sandbox Code Playgroud)