Get a process loader for a JVM. The class path for the JVM
is computed based on the class loaders for the main class.
@param mainClass Main class to run
@param args Additional command line parameters
@return ProcessBuilder that has not been started.
163996
public static ProcessBuilder getProcessBuilder(Class<?> mainClass, String...args) throws LauncherException
	{
		return getProcessBuilder(mainClass, Arrays.asList(args));
	}
122155
public static void invokeMain(String className, String[] args) {
        try {
            Class<?> clazz = null;
            if (ClassServiceUtility.getClassService().getClassFinder(null) != null)
                clazz = ClassServiceUtility.getClassService().getClassFinder(null).findClass(className, null);
            if (clazz == null)
                clazz = Class.forName(className);

            Method method = clazz.getMethod("main", PARAMS);
            Object[] objArgs = new Object[] {args};
            method.invoke(null, objArgs);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
516430
public SyncToolConfig processCommandLine(String[] args) {
        SyncToolConfig config = null;
        try {
            config = processConfigFileOptions(args);
        } catch (ParseException e) {
            printHelp(e.getMessage());
        }
        return config;
    }
1111882
public static void start(Class<?> mainClass, final String[] args) {
        try {
            LifecycleInjector.bootstrap(mainClass, new AbstractModule() {
                @Override
                protected void configure() {
                    bind(String[].class).annotatedWith(Main.class).toInstance(args);
                }
            });
        } catch (Exception e) {
            throw new ProvisionException("Error instantiating main class", e);
        }
    }
1318302
public static void main(final String[] args)
    {
        // passing true to constructor indicates the compiler is being run in standalone mode
        final VoltCompiler compiler = new VoltCompiler(true, false);

        boolean success = false;
        if (args.length > 0 && args[0].toLowerCase().endsWith(".jar")) {
            // The first argument is *.jar for the new syntax.
            if (args.length >= 2) {
                // Check for accidental .jar or .xml files specified for argument 2
                // to catch accidental incomplete use of the legacy syntax.
                if (args[1].toLowerCase().endsWith(".xml") || args[1].toLowerCase().endsWith(".jar")) {
                    System.err.println("Error: Expecting a DDL file as the second argument.\n"
                                     + "      .xml and .jar are invalid DDL file extensions.");
                    System.exit(-1);
                }
                success = compiler.compileFromDDL(args[0], ArrayUtils.subarray(args, 1, args.length));
            }
            else {
                System.err.printf("Usage: %s\n", usageNew);
                System.exit(-1);
            }
        }
        else {
            // Can't recognize the arguments or there are no arguments.
            System.err.printf("Usage: %s\n       %s\n", usageNew, usageLegacy);
            System.exit(-1);
        }

        // Should have exited if inadequate arguments were provided.
        assert(args.length > 0);

        // Exit with error code if we failed
        if (!success) {
            compiler.summarizeErrors(System.out, null);
            System.exit(-1);
        }
        compiler.summarizeSuccess(System.out, null, args[0]);
    }
485153
public ProcessBuilder processBuilder(String... arguments) {
		ProcessBuilder processBuilder = new ProcessBuilder(toString());
		processBuilder.command().addAll(Arrays.asList(arguments));
		return processBuilder;
	}
599299
public static void main(String[] args) {
    if (args.length != 0) {
      LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
          AlluxioJobMaster.class.getCanonicalName());
      System.exit(-1);
    }

    CommonUtils.PROCESS_TYPE.set(alluxio.util.CommonUtils.ProcessType.JOB_MASTER);
    AlluxioJobMasterProcess process;
    try {
      process = AlluxioJobMasterProcess.Factory.create();
    } catch (Throwable t) {
      LOG.error("Failed to create job master process", t);
      // Exit to stop any non-daemon threads.
      System.exit(-1);
      throw t;
    }
    ProcessUtils.run(process);
  }
435644
public static void main(final String[] args) {
          final JFrame j = new OSMMapTilePackagerUI();
          j.setPreferredSize(new Dimension(640, 400));
          j.setDefaultCloseOperation(EXIT_ON_CLOSE);
          j.pack();
          j.setVisible(true);
     }
1368680
@Override
    public void startAnt(final String[] args, final Properties additionalUserProperties, final ClassLoader coreLoader) {
        try {
            processArgs(args);
        } catch (final BuildException exc) {
            handleLogfile();
            printMessage(exc);
            exit(1);
            return;
        } catch (final RuntimeException e) {
            handleLogfile();
            e.printStackTrace();
            exit(1);
            return;
        } catch (final Throwable exc) {
            handleLogfile();
            printMessage(exc);
            exit(1);
            return;
        }

        if (!readyToRun) {
            return;
        }

        if (additionalUserProperties != null) {
            for (Map<String, Object> props : projectProps) {
                for (final Enumeration<Object> e = additionalUserProperties.keys(); e.hasMoreElements(); ) {
                    final String key = (String) e.nextElement();
                    final String property = additionalUserProperties.getProperty(key);
                    props.put(key, property);
                }
            }
        }

        // expect the worst
        int exitCode = 1;
        try {
            try {
                for (Map<String, Object> props : projectProps) {
                    runBuild(coreLoader, props);
                }
                exitCode = 0;
            } catch (final ExitStatusException ese) {
                exitCode = ese.getStatus();
                if (exitCode != 0) {
                    throw ese;
                }
            }
        } catch (final BuildException be) {
            if (err != System.err) {
                printMessage(be);
            }
        } catch (final Throwable exc) {
            exc.printStackTrace();
            printMessage(exc);
        } finally {
            handleLogfile();
        }
        exit(exitCode);
    }
42121
public <P extends ProcessBuilder> QueueBuilder<P> newQueueBuilder(Class<P> process_builder_class)
    {
        return QueueFactory.newQueueBuilder(this, process_builder_class);
    }
493826
public static void main(final String[] args) {
    LOG.log(Level.INFO, "Entering Launch at :::" + new Date());
    try {
      if (args == null || args.length == 0) {
        throw new IllegalArgumentException("No arguments provided, at least a clrFolder should be supplied.");
      }
      final File dotNetFolder = new File(args[0]).getAbsoluteFile();
      final String[] removedArgs = Arrays.copyOfRange(args, 1, args.length);

      final Configuration config = getClientConfiguration(removedArgs);
      final Injector commandLineInjector = Tang.Factory.getTang().newInjector(parseCommandLine(removedArgs));
      final int waitTime = commandLineInjector.getNamedInstance(WaitTimeForDriver.class);
      final int driverMemory = commandLineInjector.getNamedInstance(DriverMemoryInMb.class);
      final boolean isLocal = commandLineInjector.getNamedInstance(Local.class);
      final String driverIdentifier = commandLineInjector.getNamedInstance(DriverIdentifier.class);
      final String jobSubmissionDirectory = commandLineInjector.getNamedInstance(DriverJobSubmissionDirectory.class);
      final boolean submit = commandLineInjector.getNamedInstance(Submit.class);
      final Injector injector = Tang.Factory.getTang().newInjector(config);
      final JobClient client = injector.getInstance(JobClient.class);
      client.setDriverInfo(driverIdentifier, driverMemory, jobSubmissionDirectory);

      if (submit) {
        client.submit(dotNetFolder, true, isLocal, null);
        client.waitForCompletion(waitTime);
      } else {
        client.submit(dotNetFolder, false, isLocal, config);
        client.waitForCompletion(0);
      }


      LOG.info("Done!");
    } catch (final BindException | InjectionException | IOException ex) {
      LOG.log(Level.SEVERE, "Job configuration error", ex);
    }
  }
611246
public ProcessBuilder getProcessBuilder()
	{
		if (spawned)
			return builder; // throw new IllegalStateException("Cannot call spawn twice!");

		if (runAs != null)
		{
			String command = cmd.get(0);

			if (command.charAt(0) == '-' && !SudoFeature.hasArgumentsEnd())
				throw new IllegalArgumentException("Command to runAs starts with - but this version of sudo does not support the -- argument end token: this command cannot, therefore, be executed securely. Command was: '" +
				                                   command + "'");

			// Pass the environment in through an "env" command:
			if (this.environment.size() > 0)
			{
				for (final String key : this.environment.keySet())
				{
					final String value = this.environment.get(key);

					final String var = key + "=" + value;

					addToCmd(0, var);
				}

				// cmd.add(0,"env");
				addToCmd(0, "env");
			}

			// cmd.add(0, "--"); // doesn't work everywhere
			// cmd.add(0, runAs);
			// cmd.add(0, "-u");
			// cmd.add(0, "-n"); // Never prompt for a password: we simply cannot provide one
			// cmd.add(0, "sudo");

			if (SudoFeature.hasArgumentsEnd())
				addToCmd(0, "--");

			// If possible tell sudo to run non-interactively
			String noninteractive = SudoFeature.hasNonInteractive() ? "-n" : null;

			if (this.runAs.equals(SUPERUSER_IDENTIFIER))
			{
				addToCmd(0, "sudo", noninteractive);
			}
			else
				addToCmd(0, "sudo", noninteractive, "-u", runAs);
		}
		else
		{
			builder.environment().putAll(this.environment);
		}

		spawned = true;

		if (log.isInfoEnabled())
		{
			log.info("ProcessBuilder created for command: " + join(" ", cmd));
		}

		return builder;
	}
617533
public RetrievalToolConfig processCommandLine(String[] args) {
        RetrievalToolConfig config = null;
        try {
            config = processOptions(args);
        } catch (ParseException e) {
            printHelp(e.getMessage());
        }

        // Make sure work dir is set
        RetrievalConfig.setWorkDir(config.getWorkDir());
        config.setWorkDir(RetrievalConfig.getWorkDir());

        return config;
    }
648863
public static void main(String[] args) {
    try {
      ToolRunner.run(new ProcessingRecordsPrinter(), args);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
207440
public static void main(String[] args) {
		if (args.length != 2) {
			DEFAULT_OUT.printf("The received argument is not valid : %1$s%n",
					Arrays.toString(args));
			System.exit(-1);// NOSONAR
		}
		PowerUnit mbean = new PowerUnit();
		MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
		ObjectName name;
		try {
			name = new ObjectName("ch.powerunit.jmx:type=PowerUnit");
			mbs.registerMBean(mbean, name);
		} catch (MalformedObjectNameException | InstanceAlreadyExistsException
				| MBeanRegistrationException | NotCompliantMBeanException e1) {
			e1.printStackTrace();
		}
		String outputPath = args[0];
		String classes[] = args[1].split("\\s*,\\s*");
		StringBuilder resumedSucess = new StringBuilder();
		StringBuilder resumedFailure = new StringBuilder();
		StringBuilder resumedSkipped = new StringBuilder();

		boolean success = true;
		for (String c : classes) {
			DEFAULT_OUT.printf("Running test for %1$s%n", c);
			try {
				PowerUnitRunner r = null;
				if (c.contains(":")) {
					String param[] = c.split("\\s*:\\s*");
					Class<?> cls = Class.forName(param[0]);
					Method m = cls.getMethod(param[1]);
					r = new DefaultPowerUnitRunnerImpl(cls, m);
				} else {
					Class<?> cls = Class.forName(c);
					r = new DefaultPowerUnitRunnerImpl(cls);
				}
				DefaultTestResultListener def = new DefaultTestResultListener(
						outputPath, DEFAULT_OUT, mbean);
				r.addListener(def);
				r.run();// NOSONAR
				success &= !def.isError();
				resumedSucess.append(def.getResumedSucess());
				resumedFailure.append(def.getResumedFailure());
				resumedSkipped.append(def.getResumedSkipped());
			} catch (ClassNotFoundException e) {
				DEFAULT_OUT.printf("Unable to create the class %1$s%n", c);
			} catch (NoSuchMethodException e) {
				DEFAULT_OUT.printf(
						"Unable to create the find the method %1$s%n", c);
			} catch (SecurityException e) {
				DEFAULT_OUT
						.printf("Unable to create the test because of security issue %1$s%n",
								c);
			} finally {
				DEFAULT_OUT.printf("End running test for %1$s%n", c);
			}
		}
		DEFAULT_OUT.print("\n\nSuccess tests:\n" + resumedSucess.toString()
				+ "\n\nSkipped tests:\n" + resumedSkipped.toString()
				+ "\n\nFailed tests:\n" + resumedFailure.toString() + "\n");
		if (!success) {
			System.exit(-1);// NOSONAR
		}
		System.exit(0);// NOSONAR
	}
293954
private static void launch(String[] args, String mainClass) throws Throwable {
        EeClassLoader classLoader = new EeClassLoader();
        classLoader.invokeMain(mainClass, args);
    }
541983
@Override
	public final String process(final IoSession session, final String... args) {
		RemoteProgram remoteProgram = null;
		// Get the corresponding remoteProgram
		try {
			remoteProgram = parseCommandLine(args);

			final Class<?> jobClass = (Class<?>) remoteProgram
					.getAdapterClass();
			final Launcher launcher = Launcher.getLauncher();

			final Launch<?> launch = launcher.newLaunch(jobClass);

			for (IOption ioption : this.getOptions()) {
				ioption.process(launch, remoteProgram);
			}

			final LaunchResult launchResult = launch.synchLaunch().getLaunchResult();
			String status = null;
			String userErrorCode = null;
			if (launchResult == null) {
				status = ProgramReturnCodes.NOTSTARTED.name();
			} else {
				status = String.valueOf(launchResult.getStatusCode());
				userErrorCode = String.valueOf(launchResult.getReturnCode());
			}

			return LaunchingMessageKind.ILAUNCH0003.getFormatedMessage(
					jobClass.getCanonicalName(), launch.getLaunchId(), status, userErrorCode);
		} catch (ParseException e) {
			return e.getMessage();
		} catch (ParserException e) {
			return e.getFormatedMessage();
		} catch (OptionException e) {
			return e.getFormatedMessage();
		} catch (LaunchException e) {
			return LaunchingMessageKind.ELAUNCH0008
					.format(remoteProgram != null ? remoteProgram
							.getAdapterClass() : "unknown",e);
		} catch (Exception e) {
			return LaunchingMessageKind.ELAUNCH0008
					.format(remoteProgram != null ? remoteProgram
							.getAdapterClass() : "unknown",e.getMessage(), e);
		}
	}