在Eclipse插件,使用系统broswer如何启动一个网页的网址? [英] In Eclipse Plug-in, how to launch a web url using system broswer?

查看:142
本文介绍了在Eclipse插件,使用系统broswer如何启动一个网页的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Eclipse插件开发。它需要发射系统broswer并打开链接。在Swing / SWT,我能做到这一点是这样的:

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);

而事实上,这种code也适用于Eclipse的插件。但我想,如果日蚀以自己的方式来做到这一点?在使用AWT日食似乎某种怪异...

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...

推荐答案

等效 java.awt.Desktop.getDesktop()。浏览(URI)这是 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");
    }
}

在javadoc中说:

The javadoc says:

启动操作系统
  可执行与文件相关联或
  网址(http://或https://开头)。如果文件
  是一个可执行然后可执行
  推出。请注意,显示器必须
  已经存在以保证该
  方法返回相应的结果。

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.

这篇关于在Eclipse插件,使用系统broswer如何启动一个网页的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆