I need a button that will open my browser to a particular URL, say,
www.google.com.
Any help appreciated.
There's plenty of examples on the web of how to do this. If your code is
to run on multiple platforms you will need to use a different method for
each OS. Windows is fairly straightforward:
public void launchBrowser(URL target)
{
System.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " +
target.toString());
}
This launches whatever is the default browser (Opera, Mozilla, IE,
Netscape, whatever) for the particular URL. In fact it will launch
whatever the default viewer is for the file type (so you get Word, if it's
installed, for .doc files, etc.)
If you want to support Linux/Solaris/Mac you will need a more involved
solution (search the web).
--
Daniel Dyer
Empathy Software (http://www.empathysoftware.com)
You mixed up 'System' with 'Runtime' The following code will work:
String url = "http://www.google.com";
try {
Runtime.getRuntime().exec(
"rundll32 url.dll,FileProtocolHandler " + url);
} catch (IOException e) {
e.printStackTrace();
}
-Brock
Daniel Dyer <dan....@dontspammeempathysoftware.com> wrote in message news:<oprqjo54epiihdmk@localhost>...