private static int findJavaHome(AppConfig appConfig, JavaFinder javaFinder,
			JavaFilter javaFilter, boolean save) throws IOException {

		File javaHomeDir;
		LaunchProperties launchProperties = appConfig.getLaunchProperties();

		// PRIORITY 1: JAVA_HOME_OVERRIDE property
		// If a valid java home override is specified in the launch properties, use that.
		// Someone presumably wants to force that specific version.
		javaHomeDir = launchProperties.getJavaHomeOverride();
		if (appConfig.isSupportedJavaHomeDir(javaHomeDir, javaFilter)) {
			if (save) {
				appConfig.saveJavaHome(javaHomeDir);
			}
			System.out.println(javaHomeDir);
			return EXIT_SUCCESS;
		}
		if (javaHomeDir != null) {
			logJavaHomeError(javaHomeDir, true,
				launchProperties.getLaunchPropertiesFile().getAbsolutePath() + ", " +
					LaunchProperties.JAVA_HOME_OVERRIDE);
		}

		// PRIORITY 2: Java specified by JAVA_HOME environment
		String javaHome = System.getenv("JAVA_HOME");
		if (javaHome != null) {
			javaHomeDir = new File(javaHome);
			if (appConfig.isSupportedJavaHomeDir(javaHomeDir, javaFilter)) {
				if (save) {
					appConfig.saveJavaHome(javaHomeDir);
				}
				System.out.println(javaHomeDir);
				return EXIT_SUCCESS;
			}
		}

		// PRIORITY 3: Java on PATH
		// This program (LaunchSupport) was started with the Java on the PATH. Try to use this one 
		// next because it is most likely the one that is being upgraded on the user's system.
		javaHomeDir = javaFinder.findSupportedJavaHomeFromCurrentJavaHome(appConfig, javaFilter);
		if (javaHomeDir != null) {
			if (save) {
				appConfig.saveJavaHome(javaHomeDir);
			}
			System.out.println(javaHomeDir);
			return EXIT_SUCCESS;
		}

		// PRIORITY 4: Last used Java
		// Check to see if a prior launch resulted in that Java being saved. If so, try to use that.
		javaHomeDir = appConfig.getSavedJavaHome();
		if (appConfig.isSupportedJavaHomeDir(javaHomeDir, javaFilter)) {
			System.out.println(javaHomeDir);
			return EXIT_SUCCESS;
		}

		// PRIORITY 5: Find all supported Java installations, and use the newest.
		List<File> javaHomeDirs =
			javaFinder.findSupportedJavaHomeFromInstallations(appConfig, javaFilter);
		if (!javaHomeDirs.isEmpty()) {
			javaHomeDir = javaHomeDirs.iterator().next();
			if (save) {
				appConfig.saveJavaHome(javaHomeDir);
			}
			System.out.println(javaHomeDir);
			return EXIT_SUCCESS;
		}

		// Issue warning about incompatible JAVA_HOME
		if (javaHome != null) {
			logJavaHomeError(new File(javaHome), false, "JAVA_HOME environment");
		}

		return EXIT_FAILURE;
	}
Handles finding a Java home directory to use for the launch.  If one is successfully 
found, its path is printed to STDOUT and an exit code that indicates success is 
returned.  Otherwise, nothing is printed to STDOUT and an error exit code is returned.

@param appConfig The application configuration that defines what we support.
@param javaFinder The Java finder.
@param javaFilter A filter used to restrict what kind of Java installations we search for.
@param save True if the determined Java home directory should get saved to a file. 
@return A suggested exit code based on whether or not a supported Java home directory was 
  successfully determined.
@throws IOException if there was a problem saving the java home to disk.
GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java