code: List<String> buildJavaCommand(String extraClassPath) throws IOException {
      List<String> cmd = new ArrayList<>();
  
      String[] candidateJavaHomes = new String[] {
        javaHome,
        childEnv.get("JAVA_HOME"),
        System.getenv("JAVA_HOME"),
        System.getProperty("java.home")
      };
      for (String javaHome : candidateJavaHomes) {
        if (javaHome != null) {
          cmd.add(join(File.separator, javaHome, "bin", "java"));
          break;
        }
      }
  
      // Load extra JAVA_OPTS from conf/java-opts, if it exists.
      File javaOpts = new File(join(File.separator, getConfDir(), "java-opts"));
      if (javaOpts.isFile()) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(
            new FileInputStream(javaOpts), StandardCharsets.UTF_8))) {
          String line;
          while ((line = br.readLine()) != null) {
            addOptionString(cmd, line);
          }
        }
      }
  
      cmd.add("-cp");
      cmd.add(join(File.pathSeparator, buildClassPath(extraClassPath)));
      return cmd;
    }
docs: Builds a list of arguments to run java.
  
  This method finds the java executable to use and appends JVM-specific options for running a
  class with Spark in the classpath. It also loads options from the "java-opts" file in the
  configuration directory being used.
  
  Callers should still add at least the class to run, as well as any arguments to pass to the
  class.