public static List<String> buildJavaCommandLine(String javaExecutable,
                                                  String mainClass,
                                                  List<String> bootClasspath,
                                                  List<String> classpath,
                                                  List<String> vmParams,
                                                  List<String> programParams,
                                                  boolean shortenClasspath,
                                                  boolean preferClasspathJar) {
    List<String> cmdLine = new ArrayList<>();

    cmdLine.add(javaExecutable);

    cmdLine.addAll(vmParams);

    if (!bootClasspath.isEmpty()) {
      cmdLine.add("-bootclasspath");
      cmdLine.add(StringUtil.join(bootClasspath, File.pathSeparator));
    }

    if (!classpath.isEmpty()) {
      List<String> shortenedCp = null;

      if (shortenClasspath) {
        try {
          Charset cs = Charset.defaultCharset();  // todo detect JNU charset from VM options?
          if (isModularRuntime(javaExecutable)) {
            List<String> args = Arrays.asList("-classpath", StringUtil.join(classpath, File.pathSeparator));
            File argFile = CommandLineWrapperUtil.createArgumentFile(args, cs);
            shortenedCp = Collections.singletonList('@' + argFile.getAbsolutePath());
          }
          else if (preferClasspathJar) {
            File classpathJar = CommandLineWrapperUtil.createClasspathJarFile(new Manifest(), classpath);
            shortenedCp = Arrays.asList("-classpath", classpathJar.getAbsolutePath());
          }
          else {
            Class<?> wrapperClass = CommandLineWrapperClassHolder.ourWrapperClass;
            if (wrapperClass != null) {
              File classpathFile = CommandLineWrapperUtil.createWrapperFile(classpath, cs);
              shortenedCp = Arrays.asList(
                "-classpath", ClasspathBootstrap.getResourcePath(wrapperClass), wrapperClass.getName(), classpathFile.getAbsolutePath());
            }
            else {
              LOG.info("CommandLineWrapper class not found; classpath shortening won't be used");
            }
          }
        }
        catch (IOException e) {
          LOG.warn("can't create temp file; classpath shortening won't be used", e);
        }
      }

      // classpath
      if (shortenedCp != null) {
        cmdLine.addAll(shortenedCp);
      }
      else {
        cmdLine.add("-classpath");
        cmdLine.add(StringUtil.join(classpath, File.pathSeparator));
      }
    }

    // main class and params
    cmdLine.add(mainClass);

    cmdLine.addAll(programParams);

    return cmdLine;
  }
public static List<String> buildJavaCommandLine(String javaExecutable,
                                                  String mainClass,
                                                  List<String> bootClasspath,
                                                  List<String> classpath,
                                                  List<String> vmParams,
                                                  List<String> programParams,
                                                  boolean shortenClasspath,
                                                  boolean preferClasspathJar)