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; }
private static void appendParamsEncodingClasspath( SimpleJavaParameters javaParameters, GeneralCommandLine commandLine, ParametersList parametersList) { commandLine.addParameters(parametersList.getList()); appendEncoding(javaParameters, commandLine, parametersList); if (!parametersList.hasParameter("-classpath") && !parametersList.hasParameter("-cp") && !javaParameters.getClassPath().getPathList().isEmpty()) { commandLine.addParameter("-classpath"); commandLine.addParameter(javaParameters.getClassPath().getPathsString()); } }