How do I open a browser window via Eclipse?
Author: Deron Eriksson
Description: This tutorial describes how to open a browser window using an external tool in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1


Page: < 1 2

(Continued from page 1)

This becomes a powerful tool when you combine this technique with the expression language variables options that EclipseSW offers. As an example of this, let's create another External Tool configuration, but this time, lets use a variable. A full listing of the various variables available can be obtained by clicking on the 'Variables...' button. For this configuration, I called it 'IE - current project index.html'. Once again, IE7 is the browser used. This time, however, I include the project name via the substitution variable as part of the argument. This example relies on having TomcatSW (or another servletW container) up and running, which is something I'll cover in another lesson. The important point is that the currently selected project name gets passed to IE7 as a program argument when it fires up.

'IE - current project index.html' External Tool configuration

Back in the Eclipse Resource perspective, we can select the 'test' project so that it is the currently selected project (Tomcat also happens to be up and running). We can then click our 'IE - current project index.html' external tool in the External Tools menu.

External Tools menu

This opens IE7 with "http://localhost:8080/test/index.html" set as the URL. Note how the currently selected project name (ie, 'test') got substituted into the program argument that we passed to IE7. Very powerful!

IE7 window opens to current project's index.html

Of course, we're not limited to IE. We can do the same kind of thing for any other browser, such as Firefox:

'Firefox - Google' External Tool configuration

Try it out and have fun!

Page: < 1 2