问题
I want to select a term a term in the editor and pass it to an external URL using the default browser.
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.
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!
回答1:
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 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.

回答2:
On Mac you can use External tools and set the location to "/usr/bin/open" and in the arguments specify the path to the file you want to open:
Since the file is an HTML page, the default browser should open with it.
来源:https://stackoverflow.com/questions/24040110/how-to-open-the-default-browser-from-eclipse-user-space-on-any-platform