Class BrowserUtil

java.lang.Object
org.apache.uima.internal.util.BrowserUtil

public class BrowserUtil extends Object
The BrowserUtil class provides one static method - openUrlInDefaultBrowser, which opens the given URL in the default web browser for the current user of the system. Current implementation supports Windows, Linux and some Unix systems.
  • Field Details

    • __osId

      private static int __osId
      The internal ID of the OS we are running on
    • __browserLauncher

      private static String[] __browserLauncher
      The command that launches system browser
    • WINDOWS_NT

      private static final int WINDOWS_NT
      JVM constant for any Windows NT JVM
      See Also:
    • WINDOWS_9x

      private static final int WINDOWS_9x
      JVM constant for any Windows 9x JVM
      See Also:
    • MAC_OS

      private static final int MAC_OS
      JVM constant for MacOS JVM
      See Also:
    • OTHER

      private static final int OTHER
      JVM constant for any other platform
      See Also:
    • FIRST_WINDOWS_PARAMETER

      private static final String FIRST_WINDOWS_PARAMETER
      The first parameter that needs to be passed into Runtime.exec() to open the default web browser on Windows.
      See Also:
    • SECOND_WINDOWS_PARAMETER

      private static final String SECOND_WINDOWS_PARAMETER
      The second parameter for Runtime.exec() on Windows.
      See Also:
    • THIRD_WINDOWS_PARAMETER

      private static final String THIRD_WINDOWS_PARAMETER
      The third parameter for Runtime.exec() on Windows. This is a "title" parameter that the command line expects. Setting this parameter allows URLs containing spaces to work.
      See Also:
  • Constructor Details

    • BrowserUtil

      private BrowserUtil()
      This class should be never be instantiated; this just ensures so.
  • Method Details

    • main

      public static void main(String[] args)
      For testing only.
      Parameters:
      args - [url_to_open]
    • openUrlInDefaultBrowser

      public static Process openUrlInDefaultBrowser(String url) throws Exception
      Attempts to open the default web browser to the given URL.
      Parameters:
      url - The URL to open
      Returns:
      Returns the process browser object or null if no browser could be found. On MacOs null is returned in any case.
      Throws:
      Exception - If the available web browser does not run