private synchronized void startApplication() {
        if (openfired == null) {
            try {
                File windowsExe = new File(binDir, "openfired.exe");
                File unixExe = new File(binDir, "openfired");
                if (windowsExe.exists()) {
                    openfired = Runtime.getRuntime().exec(new String[]{windowsExe.toString()});
                }
                else if (unixExe.exists()) {
                    openfired = Runtime.getRuntime().exec(new String[]{unixExe.toString()});
                }
                else {
                    throw new FileNotFoundException();
                }
            }
            catch (Exception e) {
                // Try one more time using the jar and hope java is on the path
                try {
                    File libDir = new File(binDir.getParentFile(), "lib").getAbsoluteFile();
                    openfired = Runtime.getRuntime().exec(new String[]{
                        "java", "-jar", new File(libDir, "startup.jar").toString()
                    });
                }
                catch (Exception ex) {
                    ex.printStackTrace();
                    JOptionPane.showMessageDialog(null,
                            "Launcher could not start,\n" + appName,
                            "File not found", JOptionPane.ERROR_MESSAGE);
                }
            }

            final SimpleAttributeSet styles = new SimpleAttributeSet();
            SwingWorker<String, Void> inputWorker = new SwingWorker<>()
            {
                @Override
                public String doInBackground()
                {
                    if (openfired != null) {
                        // Get the input stream and read from it
                        try (InputStream in = openfired.getInputStream()) {
                            int c;
                            while ((c = in.read()) != -1) {
                                try {
                                    StyleConstants.setFontFamily(styles, "courier new");
                                    pane.getDocument().insertString(pane.getDocument().getLength(),
                                        "" + (char) c, styles);
                                } catch (BadLocationException e) {
                                    // Ignore.
                                }
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    return "ok";
                }
            };
            inputWorker.execute();


            SwingWorker<String, Void> errorWorker = new SwingWorker<>()
            {
                @Override
                public String doInBackground()
                {
                    if (openfired != null) {
                        // Get the input stream and read from it
                        try (InputStream in = openfired.getErrorStream()) {
                            int c;
                            while ((c = in.read()) != -1) {
                                try {
                                    StyleConstants.setForeground(styles, Color.red);
                                    pane.getDocument().insertString(pane.getDocument().getLength(), "" + (char) c, styles);
                                } catch (BadLocationException e) {
                                    // Ignore.
                                }
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    return "ok";
                }
            };
            errorWorker.execute();

            if (freshStart) {
                try {
                    Thread.sleep(1000);
                    cardLayout.show(cardPanel, "running");
                }
                catch (Exception ex) {
                    // Ignore.
                }
                freshStart = false;
            }
            else {
                 // Clear Text
                pane.setText("");
                cardLayout.show(cardPanel, "running");
            }

        }
    }
Creates a new GUI launcher instance.
@param args The command line arguments
@throws AWTException if AWT cannot be initialised
starter/src/main/java/org/jivesoftware/openfire/launcher/Launcher.java