title: How to run selenium standalone server as hub using apache commons exec?
body: <p>I am trying to start selenium-standalone-server as a hub in java program. I have tried to use ProcessBuilder and Process. I was unable to do so. Then I found Apache Commons exec library. I am able to launch selenium server. But, when I am using following code, I am not able to run the server as hub. I am trying to run this code through eclipse.</p>
  
  <pre><code>package selenium.tool.utils;
  import org.apache.commons.exec.CommandLine;
  import org.apache.commons.exec.DefaultExecutor;
  
  public class HubRunner {
  
  public HubRunner(String portNumber) {
      try {
          String cmd = "java";
  
          CommandLine cmdline = CommandLine.parse(cmd);
          cmdline.addArgument("-jar");
          cmdline.addArgument("selenium-server-standalone-2.33.0.jar");
          cmdline.addArgument("-role hub", false);
          cmdline.addArgument("-port 5454", false);
  
          System.out.println(cmdline.toString());
  
          DefaultExecutor exe = new DefaultExecutor();
          exe.execute(cmdline);
      } catch (Exception ex) {
          System.err.println(ex.getMessage());
      }
  }
  
  public static void main(String[] args) {
      HubRunner hr = new HubRunner("8888");
  }
  }
  </code></pre>
  
  <p>Ideally, this program should launch server as hub. But, it's not doing. It is omitting '-role hub' and '-port 5454' params.</p>
  
  <p>I get following output:</p>
  
  <blockquote>
    <p>java -jar selenium-server-standalone-2.33.0.jar -role hub -port 5454<br>
    Jul 28, 2013 10:42:32 PM org.openqa.grid.selenium.GridLauncher main<br>
    INFO: Launching a standalone server<br>
    22:42:33.468 INFO - Java: Sun Microsystems Inc. 14.0-b16<br>
    22:42:33.470 INFO - OS: Linux 2.6.33.3-85.fc13.i686.PAE i386<br>
    22:42:33.520 INFO - v2.33.0, with Core v2.33.0. Built from revision 4e90c97<br>
    22:42:34.111 INFO - RemoteWebDriver instances should connect to: <code>http://127.0.0.1:4444/wd/hub</code><br>
    22:42:34.115 INFO - Version Jetty/5.1.x<br>
    22:42:34.117 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]<br>
    22:42:34.119 INFO - Started HttpContext[/selenium-server,/selenium-server]<br>
    22:42:34.120 INFO - Started HttpContext[/,/]<br>
    22:42:34.182 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@13c468a<br>
    22:42:34.183 INFO - Started HttpContext[/wd,/wd]<br>
    22:42:34.200 INFO - Started SocketListener on 0.0.0.0:4444<br>
    22:42:34.200 INFO - Started org.openqa.jetty.jetty.Server@15e83f9<br></p>
  </blockquote>
  
  <p>Please help me.</p>