public static GeneralCommandLine setupJVMCommandLine(
      final String exePath,
      final SimpleJavaParameters javaParameters,
      final boolean forceDynamicClasspath) {
    final GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(exePath);

    final ParametersList vmParametersList = javaParameters.getVMParametersList();
    commandLine.getEnvironment().putAll(javaParameters.getEnv());
    commandLine.setPassParentEnvironment(javaParameters.isPassParentEnvs());

    appendParamsEncodingClasspath(javaParameters, commandLine, vmParametersList);

    final String mainClass = javaParameters.getMainClass();
    String jarPath = javaParameters.getJarPath();
    if (mainClass != null) {
      commandLine.addParameter(mainClass);
    } else if (jarPath != null) {
      commandLine.addParameter("-jar");
      commandLine.addParameter(jarPath);
    }

    commandLine.addParameters(javaParameters.getProgramParametersList().getList());

    commandLine.withWorkDirectory(javaParameters.getWorkingDirectory());

    log.debug("starting process with commandLine: " + commandLine.getCommandLineString());

    return commandLine;
  }