Class ProcessStarter


  • @NotThreadSafe
    public class ProcessStarter
    extends java.lang.Object
    Helps start a Class out of Process.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ProcessStarter args​(java.lang.Object... args)
      Starts the Process using the given command-line arguments.
      ProcessStarter env​(java.lang.String name, java.lang.Object value)
      Includes the given Environment Variable as part of the start.
      static ProcessStarter forClass​(java.lang.Class<?> target)
      Creates a new instance of the ProcessStarter class.
      java.lang.Process start()
      Executes the Class using the accumulated options.
      ProcessStarter stdErr​(java.lang.ProcessBuilder.Redirect redirect)
      Redirects the Standard Err of the Process to the given Redirect.
      ProcessStarter stdIn​(java.lang.ProcessBuilder.Redirect redirect)
      Redirects the Standard In of the Process to the given Redirect.
      ProcessStarter stdOut​(java.lang.ProcessBuilder.Redirect redirect)
      Redirects the Standard Out of the Process to the given Redirect.
      ProcessStarter sysProp​(java.lang.String name, java.lang.Object value)
      Includes the given System Property as part of the start.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • forClass

        public static ProcessStarter forClass​(java.lang.Class<?> target)
        Creates a new instance of the ProcessStarter class.
        Parameters:
        target - The Class to start. This class must have a static main() method defined in it.
        Returns:
        new ProcessStarter instance
      • sysProp

        public ProcessStarter sysProp​(java.lang.String name,
                                      java.lang.Object value)
        Includes the given System Property as part of the start.
        Parameters:
        name - The System Property Name.
        value - The System Property Value. This will have toString() invoked on it.
        Returns:
        This object instance.
      • env

        public ProcessStarter env​(java.lang.String name,
                                  java.lang.Object value)
        Includes the given Environment Variable as part of the start.
        Parameters:
        name - The Environment Variable Name.
        value - The Environment Variable Value. This will have toString() invoked on it.
        Returns:
        This object instance.
      • stdOut

        public ProcessStarter stdOut​(java.lang.ProcessBuilder.Redirect redirect)
        Redirects the Standard Out of the Process to the given Redirect.
        Parameters:
        redirect - The ProcessBuilder.Redirect to use.
        Returns:
        This object instance.
      • stdErr

        public ProcessStarter stdErr​(java.lang.ProcessBuilder.Redirect redirect)
        Redirects the Standard Err of the Process to the given Redirect.
        Parameters:
        redirect - The ProcessBuilder.Redirect to use.
        Returns:
        This object instance.
      • stdIn

        public ProcessStarter stdIn​(java.lang.ProcessBuilder.Redirect redirect)
        Redirects the Standard In of the Process to the given Redirect.
        Parameters:
        redirect - The ProcessBuilder.Redirect to use.
        Returns:
        This object instance.
      • args

        public ProcessStarter args​(java.lang.Object... args)
        Starts the Process using the given command-line arguments.
        Parameters:
        args - The arguments to use.
        Returns:
        This object instance.
      • start

        public java.lang.Process start()
                                throws java.io.IOException
        Executes the Class using the accumulated options.
        Returns:
        The Process reference.
        Throws:
        java.io.IOException - If an error occurred.