import java.io.IOException;

/**
 * This class launches the appropriate browser for the operating system the program is running on.
 * Currently only supports Windows NT/2000.  rundll32.exe in the WINNT/system32 directory is used
 * to launch the browser.
 */

public class Launcher
{
    private static final String WIN_PATH = "rundll32";
    private static final String WIN_FLAG = "url.dll,FileProtocolHandler";

    private Launcher()
    {
    }

    /**
     * function to start the Windows browser
     */
    public static void launchBrowser(String a_URL)
    {
        // first, determine what operating system the client is using
        String osName = System.getProperty("os.name");

        // Windows only, please...
        if ((osName == null) || (!osName.startsWith("Windows")))
        {
            System.out.println("Launcher.launchBrowser: ERROR!! Unsupported operating system!!");
            return;
        }

        // Command string used is:
        //      rundll32 url.dll,FileProtocolHandler http://www.yahoo.com
        final String commandString = WIN_PATH + " " + WIN_FLAG + " " + a_URL;

        // launch the Windows browser
        try
        {
            Process proc = Runtime.getRuntime().exec(commandString);
        }
        catch (IOException e)
        {
            System.out.println("Launcher.launchBrowser: Could not invoke '" + commandString + "'.\n" + e);
        }
    }

    // TEST FUNCTION ONLY
    public static void main(String[] args)
    {
        Launcher.launchBrowser("http://www.intellij.com/eap/downloads");
    }
}