Package ptolemy.actor.gui
Class BrowserLauncher
- java.lang.Object
-
- ptolemy.actor.gui.BrowserLauncher
-
public class BrowserLauncher extends java.lang.Object
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.- Since:
- Ptolemy II 3.0
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
delayExit
Set to true if we copied a file out of a jar file so that the browser could display it.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
Launch the browser on the first argument.static void
openURL(java.lang.String url)
Attempts to open the default web browser to the given URL.
-
-
-
Field Detail
-
delayExit
public static boolean delayExit
Set to true if we copied a file out of a jar file so that the browser could display it. The reason we need this flag is that the system will delete the temporary file on exit, and after openURL() is called, this Java process will exit unless we delay.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
Launch the browser on the first argument. If there is no first argument, then open http://ptolemy.eecs.berkeley.edu. Second and subsequent arguments are ignored. It is best if the first argument is an absolute URL as opposed to a relative URL.For example, to open the user's default browser on http://www.eecs.berkeley.edu
java -classpath $PTII ptolemy.actor.gui.BrowserLauncher http://www.eecs.berkeley.edu
- Parameters:
args
- An array of command line arguments. The first argument names a URL to be opened. If there is no first argument, then open http://ptolemy.eecs.berkeley.edu. Second and subsequent arguments are ignored.- Throws:
java.lang.Exception
- If there is a problem launching the browser.
-
openURL
public static void openURL(java.lang.String url) throws java.io.IOException
Attempts to open the default web browser to the given URL.We use the following strategy to find URLs that may be inside jar files:
If the string does not start with "http": see if it is a file.
If the file cannot be found, look it up in the classpath.
If the file can be found in the classpath then use the found file instead of the given URL.
If the file cannot be found in the classpath, then pass the original given URL to the browser.If the ptolemy.ptII.browser property is set, then its value is used as the value of the browser.
To always use Internet Explorer, one might invoke Ptolemy with:java -classpath $PTII -Dptolemy.ptII.browser=c:\\Program\ Files\\Internet\ Explorer\\iexplore.exe ptolemy.vergil.VergilApplication
To always use Firefox:
java -classpath $PTII -Dptolemy.ptII.browser=c:\\Program\ Files\\Mozilla\ Firefox\\firefox ptolemy.vergil.VergilApplication
- Parameters:
url
- The URL to open. It is best if the first argument is an absolute URL as opposed to a relative URL.- Throws:
java.io.IOException
- If the web browser could not be located or does not run
-
-