ij.plugin
Class BrowserLauncher

java.lang.Object
  extended by ij.plugin.BrowserLauncher
All Implemented Interfaces:
PlugIn

public class BrowserLauncher
extends java.lang.Object
implements PlugIn

This plugin implements the File/Import/URL command and the commands in the Help menu that open web pages. It is based on Eric Albert's cross-platform (Windows, 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.

This code is Copyright 1999-2001 by Eric Albert (ejalbert@cs.stanford.edu) 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

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

Constructor Summary
BrowserLauncher()
           
 
Method Summary
static void openURL(java.lang.String url)
          Attempts to open the default web browser to the given URL.
 void run(java.lang.String theURL)
          Opens the specified URL (default is the ImageJ home page).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserLauncher

public BrowserLauncher()
Method Detail

run

public void run(java.lang.String theURL)
Opens the specified URL (default is the ImageJ home page).

Specified by:
run in interface PlugIn

openURL

public static void openURL(java.lang.String url)
                    throws java.io.IOException
Attempts to open the default web browser to the given URL.

Parameters:
url - The URL to open
Throws:
java.io.IOException - If the web browser could not be located or does not run