views:

623

answers:

4

I'd like to have my Eclipse plugin cause a URL to be opened by the users' default browser. This seems like pretty standard behavior, but I haven't been able to find any docs on how to do this.

Can anyone help?

+1  A: 

Do you mean launch an external windows (IE, FireFox, ...) outside eclipse, or opening an internal "Browser" composite ?

Because on the internal side, the org.eclipse.help.ui.internal.browser.embedded.EmbeddedBrowser seems to be able to define any kind of major browser.

To open the default user's browser (as an internal or external window) is a preference defined in General/Web browser.

VonC
+4  A: 

Use Program.launch(String) from the SWT API.

(Alternatively, Java 6 introduced the Desktop class.)

McDowell
That's what we're looking for :) Thanks
bruno conde
Good suggestion. +1
VonC
+2  A: 

You are looking for:

final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser( ... );
browser.openURL(url);
John Stoneham
This is the correct answer for an Eclipse workbench. IWorkbenchBrowserSupport doc: http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/browser/IWorkbenchBrowserSupport.html
McDowell
A: 

If you want it in an external browser, you don't need to create one. This is the way:

PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL("http://www.example.com/"));
zvikico