public void launch() {

        LOGGER.info("Launching main class " + mainClass + " ...");

        try {
            File file = new File(Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI());

            List<String> arguments = new ArrayList<String>();
            arguments.add(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java");

            if (vmArguments != null) {
                LOGGER.info("VM Arguments: " + vmArguments);
                for (String vmArgument : vmArguments) {
                    arguments.add(vmArgument);
                }
            }

            arguments.add("-cp");
            arguments.add(file.getAbsolutePath());
            arguments.add(mainClass);

            ProcessBuilder processBuilder = new ProcessBuilder(arguments);
            processBuilder.redirectErrorStream(true);
            Process process = processBuilder.start();

            StreamGobbler outputGobbler = new StreamGobbler("> ", process.getInputStream(), System.out);
            outputGobbler.start();
            StreamGobbler errorGobbler = new StreamGobbler("> ", process.getErrorStream(), System.err);
            errorGobbler.start();

            process.waitFor();

            outputGobbler.interrupt();
            errorGobbler.interrupt();
        }
        catch (URISyntaxException e) {
            LOGGER.log(Level.SEVERE, "Can't find jar file", e);
        }
        catch (IOException e) {
            LOGGER.log(Level.SEVERE, "Can't build process/read process output", e);
        }
        catch (InterruptedException e) {
            LOGGER.log(Level.SEVERE, "Interrupted while waiting for launched process", e);
        }

        LOGGER.info("Launcher terminated");
    }