如何从任何平台上的Eclipse用户空间打开默认浏览器? [英] How to open the default browser from Eclipse user space on any platform?

查看:140
本文介绍了如何从任何平台上的Eclipse用户空间打开默认浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在编辑器中选择一个术语,并使用默认浏览器将其传递给外部URL。

I want to select a term a term in the editor and pass it to an external URL using the default browser.

我在SO上发现了一些有用的提示,特别是这个从外部工具调用IE的配方。但是我想打开默认浏览器,不一定是IE,而不一定在Windows中。

I found a few helpful hints on SO, especially this recipe for invoking IE from an external tool. But I would like to open the default browser, not necessarily IE, and not necessarily in Windows.

我用Windows特定的配方回答了下面的问题,但是鉴于有几种从Java API启动浏览器的配方,我认为浏览器还有一个用户可见的变量,我只是找不到它。如果你能找到,请回答这个问题。或者如果你知道这是不可能的,请让我知道。谢谢!

I answered the question below with a Windows-specific recipe, but given that there are several recipes for launching the browser from the Java API, I figured there is also an user-visible variable for the browser, and I was just unable to find it. If you are able to find that, please answer the question. Or if you know that it is impossible to do so, please let me know. Thanks!

推荐答案

要在Windows上打开默认浏览器,请使用 start 内置命令到 cmd.exe 与一个URL。下面我有一个对话框的例子,当你去运行,外部工具,外部工具配置...我压缩左窗格,因为它包含我的公司的专有信息,但重要的部分在右窗格中。

To open the default browser on Windows, use the start built-in command to cmd.exe with a URL. Below I have an example of the dialog you get when you go to Run, External Tools, External Tools Configurations... I compressed the left pane because it contains proprietary information from my company, but the part that matters is in the right pane.

Cygwin有一个类似的机制。您不需要 / c 开始参数。相反,您将使用 $ {system_path:cygstart.exe} 位置,只有参数。从我的Ubuntu命令行,我也可以运行 xdg-open 代替 cygstart.exe 打开默认浏览器。但是我找不到在所有平台上工作的方式,尽管它似乎存在于Eclipse API级别。

Cygwin has a similar mechanism. You would not need the /c and start arguments. Instead you would use ${system_path:cygstart.exe} for Location and only the url in Arguments. From my Ubuntu command-line, I can also run xdg-open in place of cygstart.exe to open the default browser. But I couldn't find a way that works the same in all platforms, although it seems to exist at the Eclipse API level.

这篇关于如何从任何平台上的Eclipse用户空间打开默认浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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