com.huguesjohnson
Class LaunchBrowser

java.lang.Object
  extended by com.huguesjohnson.LaunchBrowser

public class LaunchBrowser
extends java.lang.Object

class LaunchBrowser usage: String result=(new LaunchBrowser()).launch("http://www.wherever.com"); alternate usage: String verboseResult=(new LaunchBrowser()).launch("http://www.wherever.com",true); alternate usage: String verboseResult=(new LaunchBrowser()).launch("file://c:\\some-folder\\some-file.html",true); alternate usage: String verboseResult=(new LaunchBrowser()).launch("file:///some-dir/some-file.html",true); This has only been tested on Windows 2000, if it doesn't work on another OS please set verbose to true to debug. I can just about guarantee this will not work with OS/2, the algorithm to lookup the operating system explicitly checks for Windows and MacOS with the default being UNIX/Linux. UNIX/Linux is considered the default because each "flavor" of UNIX/Linux returns a different name to the System.getProperty("os.name") call.. there is no standard name. For example, HP-UX returns "HP-UX" while Solaris returns "Solaris". This also assumes that if UNIX/Linux is the OS, then netscape is installed. As far as I know there is no way to pass UNIX/Linux an URL and have it figure out the default browser. Should this implement runnable?

Author:
Hugues Johnson

Constructor Summary
LaunchBrowser()
          constructor
 
Method Summary
 java.lang.String launch(java.lang.String url)
          Launches a web browser with the specified url.
 java.lang.String launch(java.lang.String url, boolean verbose)
          Launches a web browser with the specified url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LaunchBrowser

public LaunchBrowser()
constructor

Method Detail

launch

public java.lang.String launch(java.lang.String url)
Launches a web browser with the specified url. First tries to use current browser session, if no browser is loaded it starts a new session. See comments for the class for proper usage and known issues.

Parameters:
url - the address to open

launch

public java.lang.String launch(java.lang.String url,
                               boolean verbose)
Launches a web browser with the specified url. First tries to use current browser session, if no browser is loaded it starts a new session. See comments for the class for proper usage and known issues.

Parameters:
url - the address to open
verbose - whether or not to return verbose output, useful for debugging. This is false if launch(url) is used.


Copyright © 2004-2006 Hugues Johnson