net.i2p.apps.systray

## Class UrlLauncher

- java.lang.Object
- - net.i2p.apps.systray.UrlLauncher

- All Implemented Interfaces:
    ClientApp

      public class UrlLauncher
      extends Object
      implements ClientApp

  A quick and simple multi-platform URL launcher. It attempts to launch the default browser for the host platform first, then popular third-party browsers if that was not successful.

  Handles Galeon, Internet Explorer, Falkon, Konqueror, Links, Lynx, Mozilla, Mozilla Firefox, Netscape, Opera, and Safari.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UrlLauncher()` Constructor from SysTray
    `UrlLauncher(I2PAppContext context, ClientAppManager mgr, String[] args)` ClientApp constructor used from clients.config

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getDisplayName()` ClientApp interface
    `String` | `getName()` ClientApp interface
    `ClientAppState` | `getState()` ClientApp interface
    `static void` | `main(String[] args)` Obsolete, now uses ClientApp interface
    `boolean` | `openUrl(String url)` Discovers the operating system the installer is running under and tries to launch the given URL using the default browser for that platform; if unsuccessful, an attempt is made to launch the URL using the most common browsers.
    `boolean` | `openUrl(String url, String browser)` Opens the given URL with the given browser.
    `void` | `shutdown(String[] args)` ClientApp interface
    `void` | `startup()` ClientApp interface As of 0.9.46, stops immediately if JVM is a Windows or Linux Service.

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

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

- - ### Constructor Detail

    - #### UrlLauncher

          public UrlLauncher()

      Constructor from SysTray

    - #### UrlLauncher

          public UrlLauncher(I2PAppContext context,
                             ClientAppManager mgr,
                             String[] args)

      ClientApp constructor used from clients.config
      Parameters:
        `mgr` - null OK
        `args` - URL in args[0] or null args for router console

  - ### Method Detail

    - #### getDisplayName

          public String getDisplayName()

      ClientApp interface
      Specified by:
        `getDisplayName` in interface `ClientApp`
      Returns:
        non-null

    - #### getName

          public String getName()

      ClientApp interface
      Specified by:
        `getName` in interface `ClientApp`
      Returns:
        non-null

    - #### getState

          public ClientAppState getState()

      ClientApp interface
      Specified by:
        `getState` in interface `ClientApp`
      Returns:
        non-null

    - #### main

          public static void main(String[] args)

      Obsolete, now uses ClientApp interface

    - #### openUrl

          public boolean openUrl(String url)
                          throws IOException

      Discovers the operating system the installer is running under and tries to launch the given URL using the default browser for that platform; if unsuccessful, an attempt is made to launch the URL using the most common browsers. As of 0.9.46, fails immediately if JVM is a Windows or Linux Service. BLOCKING. This repeatedly probes the server port at the given url until it is apparently ready.
      Parameters:
        `url` - The URL to open.
      Returns:
        `true` if the operation was successful, otherwise `false`.
      Throws:
        `IOException`

    - #### openUrl

          public boolean openUrl(String url,
                                 String browser)
                          throws IOException

      Opens the given URL with the given browser. As of 0.9.38, the browser parameter will be parsed into arguments separated by spaces or tabs. %1, if present, will be replaced with the url. Arguments may be surrounded by single or double quotes if they contain spaces or tabs. There is no mechanism to escape quotes or other chars with backslashes. BLOCKING. However, this does NOT probe the server port to see if it is ready.
      Parameters:
        `url` - The URL to open.
        `browser` - The browser to use. See above for quoting rules.
      Returns:
        `true` if the operation was successful, otherwise `false`.
      Throws:
        `IOException`

    - #### shutdown

          public void shutdown(String[] args)

      ClientApp interface
      Specified by:
        `shutdown` in interface `ClientApp`
      Parameters:
        `args` - generally null but could be stopArgs from clients.config

    - #### startup

          public void startup()

      ClientApp interface As of 0.9.46, stops immediately if JVM is a Windows or Linux Service.
      Specified by:
        `startup` in interface `ClientApp`