Reputation: 4961
I am working on an eclipse plugin development. It needs to launch system broswer and open a link. In Swing/SWT, I can do it like this:
java.net.URI uri = new java.net.URI("http://www.google.com");
java.awt.Desktop.getDesktop().browse(uri);
And in fact, this code also works in Eclipse plug-in. But I am wondering if eclipse has its own way to do this? Using AWT in eclipse seems some kind of weird...
Upvotes: 4
Views: 3820
Reputation: 13984
Equivalent of java.awt.Desktop.getDesktop().browse(uri)
is this Program.launch("http://www.google.com");
import org.eclipse.swt.program.Program;
public class del
{
public static void main(String[] args)
{
Program.launch("http://www.google.com");
}
}
The javadoc says:
Launches the operating system executable associated with the file or URL (http:// or https://). If the file is an executable then the executable is launched. Note that a Display must already exist to guarantee that this method returns an appropriate result.
Upvotes: 6