title: How to call launch() more than once in java
body: <p>How to call the launch() more than once in java i am given an exception as "ERROR IN MAIN:java.lang.IllegalStateException: Application launch must not be called more than once"</p>
  
  <p>I have create rest cleint in my java application when request comes it call javafx and opening webview after completing webview operarion am closing javafx windows using   Platform.exit() method. when second request comes am getting this error how to reslove this error.</p>
  
  <p>JavaFx Application Code:</p>
  
  <pre><code>public class AppWebview extends Application  {
  
      public static Stage stage;
  
      @Override
      public void start(Stage _stage) throws Exception {
  
          stage = _stage;
          StackPane root = new StackPane();
  
          WebView view = new WebView();
  
          WebEngine engine = view.getEngine();
          engine.load(PaymentServerRestAPI.BROWSER_URL);
          root.getChildren().add(view);
          engine.setJavaScriptEnabled(true);
          Scene scene = new Scene(root, 800, 600);
          stage.setScene(scene);
  
          engine.setOnResized(new EventHandler&lt;WebEvent&lt;Rectangle2D&gt;&gt;() {
              public void handle(WebEvent&lt;Rectangle2D&gt; ev) {
                  Rectangle2D r = ev.getData();
                  stage.setWidth(r.getWidth());
                  stage.setHeight(r.getHeight());
              }
          });
  
          JSObject window = (JSObject) engine.executeScript("window");
          window.setMember("app", new BrowserApp());
  
          stage.show();
  
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  </code></pre>
  
  <p>RestClient Method:
  Calling to JavaFX application</p>
  
  <pre><code>// method 1 to lanch javafx
  javafx.application.Application.launch(AppWebview.class);
  
  // method 2 to lanch javafx
  String[] arguments = new String[] {"123"};
  AppWebview .main(arguments);
  </code></pre>