title: Open Browser window from Java program
body: <p><strong>Question</strong></p>
  
  <p>I have an application written in Java.  It is designed to run on a Linux box standalone.  I am trying to spawn a new <em>firefox</em> window.  However, <em>firefox</em> never opens.  It always has a shell exit code of 1.  I can run this same code with <em>gnome-terminal</em> and it opens fine.</p>
  
  <p><strong>Background</strong></p>
  
  <p>So, here is its initialization process:</p>
  
  <ol>
  <li>Start X "Xorg :1 -br -terminate -dpms -quiet vt7"</li>
  <li>Start Window Manager "metacity --display=:1 --replace"</li>
  <li>Configure resources "xrdb -merge /etc/X11/Xresources"</li>
  <li>Become a daemon and disconnect from controlling terminal</li>
  </ol>
  
  <p>Once the program is up an running, there is a button the user can click that should spawn a firefox window.  Here is my code to do that.  Remember X is running on display :1.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>
  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;
    }
  }
  </code></pre>