Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
BrowserLauncher Class Reference
Inheritance diagram for BrowserLauncher:
PlugIn

Public Member Functions

void run (String theURL)
 
 BrowserLauncher ()
 

Static Public Member Functions

static void openURL (String url) throws IOException
 

Detailed Description

This plugin implements ImageJ's Help/ImageJ Web Site command. It is a slightly modified version of Eric Albert's cross-platform (Windows, Mac, Mac OS X and Unix) BrowserLauncher class.

BrowserLauncher is a class that provides one static method, openURL, which opens the default web browser for the current user of the system to the given URL. It may support other protocols depending on the system – mailto, ftp, etc. – but that has not been rigorously tested and is not guaranteed to work.

Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms that are not part of the standard JDK. What we're trying to do, though, is to take something that's frequently desirable but inherently platform-specific – opening a default browser – and allow programmers (you, for example) to do so without worrying about dropping into native code or doing anything else similarly evil.

Anyway, this code is completely in Java and will run on all JDK 1.1-compliant systems without modification or a need for additional libraries. All classes that are required on certain platforms to allow this to run are dynamically loaded at runtime via reflection and, if not found, will not cause this to do anything other than returning an error when opening the browser.

There are certain system requirements for this class, as it's running through Runtime.exec(), which is Java's way of making a native system call. Currently, this requires that a Macintosh have a Finder which supports the GURL event, which is true for Mac OS 8.0 and 8.1 systems that have the Internet Scripting AppleScript dictionary installed in the Scripting Additions folder in the Extensions folder (which is installed by default as far as I know under Mac OS 8.0 and 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems (Windows 95, 98, and NT 4.0, as well as later versions of all). On other systems, this drops back from the inherently platform-sensitive concept of a default browser and simply attempts to launch Netscape via a shell command.

This code is Copyright 1999-2001 by Eric Albert (ejalb.nosp@m.ert@.nosp@m.cs.st.nosp@m.anfo.nosp@m.rd.ed.nosp@m.u) and may be redistributed or modified in any form without restrictions as long as the portion of this comment from this paragraph through the end of the comment is not removed. The author requests that he be notified of any application, applet, or other binary that makes use of this code, but that's more out of curiosity than anything and is not required. This software includes no warranty. The author is not repsonsible for any loss of data or functionality or any adverse or unexpected effects of using this software.

Credits:
Steven Spencer, JavaWorld magazine (Java Tip 66)
Thanks also to Ron B. Yeh, Eric Shapiro, Ben Engber, Paul Teitlebaum, Andrea Cantatore, Larry Barowski, Trevor Bedzek, Frank Miedrich, and Ron Rabakukk

Author
Eric Albert (ejalbert@cs.stanford.edu)
Version
1.4b1 (Released June 20, 2001)

Definition at line 60 of file BrowserLauncher.java.

Constructor & Destructor Documentation

BrowserLauncher ( )
inline

This class should be never be instantiated; this just ensures so.

Definition at line 249 of file BrowserLauncher.java.

Member Function Documentation

static void openURL ( String  url) throws IOException
inlinestatic

Attempts to open the default web browser to the given URL.

Parameters
urlThe URL to open
Exceptions
IOExceptionIf the web browser could not be located or does not run

Definition at line 392 of file BrowserLauncher.java.

void run ( String  theURL)
inline

Opens the specified URL (default is the ImageJ home page).

Implements PlugIn.

Definition at line 63 of file BrowserLauncher.java.


The documentation for this class was generated from the following file: