Module ij
Package ij.plugin

# Class BrowserLauncher

java.lang.Object
ij.plugin.BrowserLauncher

All Implemented Interfaces:
  `PlugIn`

public class BrowserLauncher extends 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

Constructors
Constructor
Description
`BrowserLauncher()`

## Method Summary

Modifier and Type
Method
Description
`static String`
`open(String url)`
Opens the specified URL in the default browser.
`static void`
`openURL(String url)`
Attempts to open the default web browser to the given URL.
`void`
`run(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 Details

### BrowserLauncher

public BrowserLauncher()

## Method Details

### run

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

Specified by:
  `run` in interface `PlugIn`

### open

public static String open(String url)
Opens the specified URL in the default browser. Returns a message if there is an error. Call from a macro using:
call("ij.plugin.BrowserLauncher.open",url);

### openURL

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

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