Class ApplicationLauncher

java.lang.Object
org.fest.swing.launcher.ApplicationLauncher

public class ApplicationLauncher extends Object
Understands execution of a Java application from a class that has a "main" method.

The following example shows how to start an application without any arguments:

 ApplicationLauncher.application(JavaApp.class).start();

 // or

 ApplicationLauncher.application("org.fest.swing.application.JavaApp").start();
 

The following example shows how to start an application with arguments:

 ApplicationLauncher.application(JavaApp.class).withArgs("arg1", "arg2").start();

 // or

 ApplicationLauncher.application("org.fest.swing.application.JavaApp").withArgs("arg1", "arg2").start();
 

  • Field Details

    • applicationType

      private final Class<?> applicationType
    • args

      private String[] args
  • Constructor Details

    • ApplicationLauncher

      private ApplicationLauncher(Class<?> applicationType)
  • Method Details

    • application

      public static ApplicationLauncher application(String applicationTypeName)
      Starting point of the fluent interface.
      Parameters:
      applicationTypeName - the fully qualified name of the class containing the "main" method.
      Returns:
      the created ApplicationStarter.
      Throws:
      UnexpectedException - if the class specified in the given name cannot be loaded.
    • application

      public static ApplicationLauncher application(Class<?> applicationType)
      Starting point of the fluent interface.
      Parameters:
      applicationType - the class containing the "main" method.
      Returns:
      the created ApplicationStarter.
    • withArgs

      public ApplicationLauncher withArgs(String... newArgs)
      Specifies the arguments to pass to the "main" method. Please note that the arguments to pass are specific to your application. JVM-specific arguments are ignored (e.g. -Xms, -Xmx)
      Parameters:
      newArgs - the arguments to pass to the "main" method.
      Returns:
      this ApplicationStarter.
      Throws:
      NullPointerException - if newArgs is null.
    • start

      public void start()
      Starts the application.
      Throws:
      org.fest.reflect.exception.ReflectionError - if the "main" method cannot be invoked.