net.sourceforge.jnlp

## Class Launcher

- java.lang.Object
- - net.sourceforge.jnlp.Launcher

-     public class Launcher
      extends java.lang.Object

  Launches JNLPFiles either in the foreground or background.

  An optional LaunchHandler can be specified that is notified of warning and error condition while launching and that indicates whether a launch may proceed after a warning has occurred. If specified, the LaunchHandler is notified regardless of whether the file is launched in the foreground or background.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Launcher(boolean exitOnFailure)` Create a launcher with the runtime's default update policy and launch handler.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected AppletInstance` | `createApplet(JNLPFile file, boolean enableCodeBase, java.awt.Container cont)` Create an AppletInstance.
    `protected java.applet.Applet` | `createAppletObject(JNLPFile file, boolean enableCodeBase, java.awt.Container cont)` Creates an Applet object from a JNLPFile.
    `protected ApplicationInstance` | `createApplication(JNLPFile file)` Creates an Application.
    `protected java.lang.ThreadGroup` | `createThreadGroup(JNLPFile file)` Create a thread group for the JNLP file.
    `protected ApplicationInstance` | `getApplet(JNLPFile file, boolean enableCodeBase, java.awt.Container cont)` Gets an ApplicationInstance, but does not launch the applet.
    `UpdatePolicy` | `getUpdatePolicy()`
    `boolean` | `isCreateAppContext()`
    `ApplicationInstance` | `launch(JNLPFile file)` Launches a JNLP file by calling the launch method for the appropriate file type.
    `ApplicationInstance` | `launch(JNLPFile file, java.awt.Container cont)` Launches a JNLP file inside the given container if it is an applet.
    `ApplicationInstance` | `launch(java.net.URL location)` Launches a JNLP file by calling the launch method for the appropriate file type.
    `protected ApplicationInstance` | `launchApplet(JNLPFile file, boolean enableCodeBase, java.awt.Container cont)` Launches a JNLP applet.
    `protected ApplicationInstance` | `launchApplication(JNLPFile file)` Launches a JNLP application.
    `void` | `launchExternal(java.util.List<java.lang.String> vmArgs, JNLPFile file, java.util.List<java.lang.String> javawsArgs)` Launches the JNLP file in a new JVM instance.
    `void` | `launchExternal(java.util.List<java.lang.String> vmArgs, java.util.List<java.lang.String> javawsArgs)` Launches the JNLP file at the specified location in a new JVM instance.
    `void` | `launchExternal(java.net.URL url)` Launches the JNLP file in a new JVM instance.
    `protected ApplicationInstance` | `launchInstaller(JNLPFile file)` Launches a JNLP installer.
    `void` | `setCreateAppContext(boolean context)` Sets whether to launch the application in a new AppContext (a separate event queue, look and feel, etc).
    `void` | `setInformationToMerge(java.util.Map<java.lang.String,java.util.List<java.lang.String>> input)` Set a map to use when trying to extract extra information, including arguments, properties and parameters, to be merged into the main JNLP
    `void` | `setParserSettings(ParserSettings settings)`
    `void` | `setUpdatePolicy(UpdatePolicy policy)` Sets the update policy used by launched applications.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Launcher

          public Launcher(boolean exitOnFailure)

      Create a launcher with the runtime's default update policy and launch handler.
      Parameters:
        `exitOnFailure` - Exit if there is an error (usually default, but false when being used from the plugin)

  - ### Method Detail

    - #### setUpdatePolicy

          public void setUpdatePolicy(UpdatePolicy policy)

      Sets the update policy used by launched applications.
      Parameters:
        `policy` - to be used for resources

    - #### getUpdatePolicy

          public UpdatePolicy getUpdatePolicy()

      Returns:
        the update policy used when launching applications.

    - #### setCreateAppContext

          public void setCreateAppContext(boolean context)

      Sets whether to launch the application in a new AppContext (a separate event queue, look and feel, etc). If the sun.awt.SunToolkit class is not present then this method has no effect. The default value is true.
      Parameters:
        `context` - appcontext to be set

    - #### isCreateAppContext

          public boolean isCreateAppContext()

      Returns:
        whether applications are launched in their own AppContext.

    - #### setParserSettings

          public void setParserSettings(ParserSettings settings)

      Parameters:
        `settings` - the parser settings to use when the Launcher initiates parsing of a JNLP file.

    - #### setInformationToMerge

          public void setInformationToMerge(java.util.Map<java.lang.String,java.util.List<java.lang.String>> input)

      Set a map to use when trying to extract extra information, including arguments, properties and parameters, to be merged into the main JNLP
      Parameters:
        `input` - a map containing extra information to add to the main JNLP. the values for keys "arguments", "parameters", and "properties" are used.

    - #### launch

          public ApplicationInstance launch(JNLPFile file)
                                     throws LaunchException

      Launches a JNLP file by calling the launch method for the appropriate file type. The application will be started in a new window.
      Parameters:
        `file` - the JNLP file to launch
      Returns:
        the application instance
      Throws:
        `LaunchException` - if an error occurred while launching (also sent to handler)

    - #### launch

          public ApplicationInstance launch(JNLPFile file,
                                            java.awt.Container cont)
                                     throws LaunchException

      Launches a JNLP file inside the given container if it is an applet. Specifying a container has no effect for Applcations and Installers.
      Parameters:
        `file` - the JNLP file to launch
        `cont` - the container in which to place the application, if it is an applet
      Returns:
        the application instance
      Throws:
        `LaunchException` - if an error occurred while launching (also sent to handler)

    - #### launch

          public ApplicationInstance launch(java.net.URL location)
                                     throws LaunchException

      Launches a JNLP file by calling the launch method for the appropriate file type.
      Parameters:
        `location` - the URL of the JNLP file to launch location to get the pristine version
      Returns:
        the application instance
      Throws:
        `LaunchException` - if there was an exception

    - #### launchExternal

          public void launchExternal(java.util.List<java.lang.String> vmArgs,
                                     JNLPFile file,
                                     java.util.List<java.lang.String> javawsArgs)
                              throws LaunchException

      Launches the JNLP file in a new JVM instance. All streams are properly redirected.
      Parameters:
        `vmArgs` - the arguments to pass to the new JVM. Can be empty but must not be null.
        `file` - the JNLP file to launch
        `javawsArgs` - the arguments to pass to the javaws command. Can be an empty list but must not be null.
      Throws:
        `LaunchException` - if there was an exception

    - #### launchExternal

          public void launchExternal(java.net.URL url)
                              throws LaunchException

      Launches the JNLP file in a new JVM instance. All streams are properly redirected.
      Parameters:
        `url` - the URL of the JNLP file to launch
      Throws:
        `LaunchException` - if there was an exception

    - #### launchExternal

          public void launchExternal(java.util.List<java.lang.String> vmArgs,
                                     java.util.List<java.lang.String> javawsArgs)
                              throws LaunchException

      Launches the JNLP file at the specified location in a new JVM instance. All streams are properly redirected.
      Parameters:
        `vmArgs` - the arguments to pass to the jvm
        `javawsArgs` - the arguments to pass to javaws (aka Netx)
      Throws:
        `LaunchException` - if there was an exception

    - #### launchApplication

          protected ApplicationInstance launchApplication(JNLPFile file)
                                                   throws LaunchException

      Launches a JNLP application. This method should be called from a thread in the application's thread group.
      Parameters:
        `file` - jnlpfile - source of application
      Returns:
        application to be launched
      Throws:
        `LaunchException` - if launch fails on unrecoverable exception

    - #### launchApplet

          protected ApplicationInstance launchApplet(JNLPFile file,
                                                     boolean enableCodeBase,
                                                     java.awt.Container cont)
                                              throws LaunchException

      Launches a JNLP applet. This method should be called from a thread in the application's thread group.

      The enableCodeBase parameter adds the applet's codebase to the locations searched for resources and classes. This can slow down the applet loading but allows browser-style applets that don't use JAR files exclusively to be run from a applet JNLP file. If the applet JNLP file does not specify any resources then the code base will be enabled regardless of the specified value.

      Parameters:
        `file` - the JNLP file
        `enableCodeBase` - whether to add the codebase URL to the classloader
        `cont` - container where to put application
      Returns:
        application
      Throws:
        `LaunchException` - if deploy unrecoverably die

    - #### getApplet

          protected ApplicationInstance getApplet(JNLPFile file,
                                                  boolean enableCodeBase,
                                                  java.awt.Container cont)
                                           throws LaunchException

      Gets an ApplicationInstance, but does not launch the applet.
      Parameters:
        `file` - the JNLP file
        `enableCodeBase` - whether to add the codebase URL to the classloader
        `cont` - container where to put applet
      Returns:
        applet
      Throws:
        `LaunchException` - if deploy unrecoverably die

    - #### launchInstaller

          protected ApplicationInstance launchInstaller(JNLPFile file)
                                                 throws LaunchException

      Launches a JNLP installer. This method should be called from a thread in the application's thread group.
      Parameters:
        `file` - jnlp file to read installer from
      Returns:
        application
      Throws:
        `LaunchException` - if deploy unrecoverably die

    - #### createApplet

          protected AppletInstance createApplet(JNLPFile file,
                                                boolean enableCodeBase,
                                                java.awt.Container cont)
                                         throws LaunchException

      Create an AppletInstance.
      Parameters:
        `file` - the JNLP file
        `enableCodeBase` - whether to add the codebase URL to the classloader
        `cont` - container where to put applet
      Returns:
        applet
      Throws:
        `LaunchException` - if deploy unrecoverably die

    - #### createAppletObject

          protected java.applet.Applet createAppletObject(JNLPFile file,
                                                          boolean enableCodeBase,
                                                          java.awt.Container cont)
                                                   throws LaunchException

      Creates an Applet object from a JNLPFile. This is mainly to be used with gcjwebplugin.
      Parameters:
        `file` - the PluginBridge to be used.
        `enableCodeBase` - whether to add the code base URL to the classloader.
        `cont` - container where to put applet
      Returns:
        applet
      Throws:
        `LaunchException` - if deploy unrecoverably dien

    - #### createApplication

          protected ApplicationInstance createApplication(JNLPFile file)
                                                   throws LaunchException

      Creates an Application.
      Parameters:
        `file` - the JNLP file
      Returns:
        application
      Throws:
        `LaunchException` - if deploy unrecoverably die

    - #### createThreadGroup

          protected java.lang.ThreadGroup createThreadGroup(JNLPFile file)

      Create a thread group for the JNLP file.
      Parameters:
        `file` - the JNLP file Note: if the JNLPFile is an applet (ie it is a subclass of PluginBridge) then this method simply returns the existing ThreadGroup. The applet ThreadGroup has to be created at an earlier point in the applet code.
      Returns:
        ThreadGroup for this app/applet

Submit a bug or feature