public static void main(String[] args) {

		int exitCode = EXIT_FAILURE; // failure by default

		// Validate command line arguments
		if (args.length < 2 || args.length > 4) {
			System.err.println("LaunchSupport expected 2 to 4 arguments but got " + args.length);
			System.exit(exitCode);
		}

		// Parse command line arguments
		int argIx = 0;
		String installDirPath = args[argIx++];
		String mode = args[argIx++];
		String checkPath = null;
		if ("-java_home_check".equals(mode)) {
			checkPath = args[argIx++];
		}

		if (!"-java_home".equals(mode) && !"-jdk_home".equals(mode) && argIx != args.length) {
			System.err.println("LaunchSupport received illegal argument: " + args[argIx]);
			System.exit(exitCode);
		}

		boolean ask = false;
		boolean save = false;

		for (int i = argIx; i < args.length; i++) {
			if (args[i].equals("-ask")) {
				ask = true;
			}
			else if (args[i].equals("-save")) {
				save = true;
			}
			else {
				System.err.println("LaunchSupport received illegal argument: " + args[i]);
				System.exit(exitCode);
			}
		}

		try {

			File installDir = new File(installDirPath).getCanonicalFile(); // change relative path to absolute
			AppConfig appConfig = new AppConfig(installDir);
			JavaFinder javaFinder = JavaFinder.create();

			// Pass control to a mode-specific handler
			switch (mode.toLowerCase()) {
				case "-java_home":
					exitCode = handleJavaHome(appConfig, javaFinder, JavaFilter.ANY, ask, save);
					break;
				case "-java_home_check":
					if (appConfig.isSupportedJavaHomeDir(new File(checkPath), JavaFilter.ANY)) {
						exitCode = EXIT_SUCCESS;
					}
					break;
				case "-jdk_home":
					exitCode =
						handleJavaHome(appConfig, javaFinder, JavaFilter.JDK_ONLY, ask, save);
					break;
				case "-vmargs":
					exitCode = handleVmArgs(appConfig);
					break;
				default:
					System.err.println("LaunchSupport received illegal argument: " + mode);
					break;
			}
		}
		catch (Exception e) {
			System.err.println(e.getMessage());
		}

		System.exit(exitCode);
	}
{@link LaunchSupport} entry point.  Uses standard exit codes to tell the user if 
the desired operation succeeded for failed.

@param args [INSTALL_DIR] [-java_home | -jdk_home | -vmargs | -java_home_check &lt;path&gt;] [-ask | -save]
<ul>
  <li><b>-java_home: </b> Get Java home (JDK or JRE) and output on stdout.</li>
  <li><b>-jdk_home: </b> Get Java home (JDK only) and output on stdout.</li>
  <li><b>-jdk_home_check: </b> Verify that the specified Java home directory contains a 
                          supported version of java.  No output is produced.</li>
  <li><b>-vmargs: </b> Get JVM arguments and output on stdout (one per line).</li>
</ul>
Optional arguments supported by -java_home and -jdk_home:
<ul>
  <li><b>-ask: </b> Interactively ask the user to choose a Java home.</li>
  <li><b>-save: </b> Save Java home to file for future use.</li>
</ul>
GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java