public void execute()

in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/RunPlatformAppMojo.java [96:180]


    public void execute() throws MojoExecutionException, MojoFailureException {
        if (!"nbm-application".equals(project.getPackaging())) {
            throw new MojoFailureException("The nbm:run-platform goal shall be used within a NetBeans Application project only ('nbm-application' packaging)");
        }

        netbeansUserdir.mkdirs();

        File appbasedir = new File(outputDirectory, brandingToken);

        if (!appbasedir.exists()) {
            throw new MojoExecutionException("The directory that shall contain built application, doesn't exist ("
                    + appbasedir.getAbsolutePath() + ")\n Please invoke 'mvn install' on the project first");
        }

        boolean windows = Os.isFamily("windows");

        Commandline cmdLine = new Commandline();
        File exec;
        if (windows) {
            exec = new File(appbasedir, "bin" + brandingToken + "_w.exe");
            if (!exec.exists()) { // Was removed as of nb 6.7
                exec = new File(appbasedir, "bin\\" + brandingToken + ".exe");
                // if jdk is 32 or 64-bit
                String jdkHome = System.getenv("JAVA_HOME");
                if (jdkHome != null) {
                    /* Detect whether the JDK is 32-bit or 64-bit. Since Oracle has "no plans to ship 32-bit builds of
                    JDK 9" [1] or beyond, assume 64-bit unless we can positively identify the JDK as 32-bit. The file
                    below is confirmed to exist on 32-bit Java 8, Java 9, and Java 10 [2], and confirmed _not_ to exist
                    on 64-bit Oracle Java 10 nor on OpenJDK 8, 9, or 10.

                    [1] Mark Reinhold on 2017-09-25
                        https://twitter.com/mreinhold/status/912311207935090689
                    [2] Downloaded from https://www.azul.com/downloads/zulu/zulu-windows on 2018-09-05. */
                    if (!new File(jdkHome, "jre\\bin\\JavaAccessBridge-32.dll").exists()
                            && // 32-bit Java 8
                            !new File(jdkHome, "\\bin\\javaaccessbridge-32.dll").exists()) // 32-bit Java 9 or 10
                    {
                        File exec64 = new File(appbasedir, "bin\\" + brandingToken + "64.exe");
                        if (exec64.isFile()) {
                            exec = exec64;
                        }
                    }
                }
                cmdLine.addArguments(new String[]{
                    "--console", "suppress"
                });
            }
        } else {
            exec = new File(appbasedir, "bin/" + brandingToken);
        }

        cmdLine.setExecutable(exec.getAbsolutePath());

        try {

            List<String> args = new ArrayList<>();
            args.add("--userdir");
            args.add(netbeansUserdir.getAbsolutePath());
            args.add("-J-Dnetbeans.logger.console=true");
            args.add("-J-ea");
            args.add("--branding");
            args.add(brandingToken);

            // use JAVA_HOME if set
            if (System.getenv("JAVA_HOME") != null) {
                args.add("--jdkhome");
                args.add(System.getenv("JAVA_HOME"));
            }

            cmdLine.addArguments(args.toArray(new String[0]));
            cmdLine.addArguments(CommandLineUtils.translateCommandline(additionalArguments));
            cmdLine.addArguments(CommandLineUtils.translateCommandline(getDebugAdditionalArguments()));
            getLog().info("Executing: " + cmdLine);
            StreamConsumer out = new StreamConsumer() {

                @Override
                public void consumeLine(String line) {
                    getLog().info(line);
                }
            };
            CommandLineUtils.executeCommandLine(cmdLine, out, out);
        } catch (Exception e) {
            throw new MojoExecutionException("Failed executing NetBeans", e);
        }
    }