title: Restart jboss as 7 programmatically
body: <p>I'm able to restart JBoss AS 7.2.0 Final using Jboss CLI with the following command:</p>
  
  <pre><code>jboss-cli.bat --connect --controller=IP:9999 --command=:shutdown(restart=true)
  </code></pre>
  
  <p>Now i need to do it programmatically from a java class, i've tried using the Jboss cli API, here after my code, but it only performs a shutdonw and doesn't restart!</p>
  
  <pre><code>CommandContext ctx = null;
  try {
    ctx = org.jboss.as.cli.CommandContextFactory.getInstance().newCommandContext();
    ctx.connectController(IP, 9999);
  
    ctx.handle(":shutdown(restart=true)");
  
  } catch (CommandLineException e) {
    System.out.println(e.getMessage());
  }
  </code></pre>
  
  <p>Any idea please?</p>