views:

28

answers:

1

I want to use Eclipse as my editor for HTML/Javascript files. When I "Run", I would like to see a browser (any one of Internet Explorer, Firefox, etc on Windows) launched for my file. How can I set up a 'run configuration' to do this?

A: 

You could set up an External Tool configuration that, when you run it, would open, in a browser, the document you're currently editing. Instead of "Run", you'd click the button next to the Run button, with the little red suitcase over it.

To set it up, use the menus: Run...External Tools...External Tools Configurations. You'll get a configuration dialog. Now:

  • Give your config a Name (like "view in Firefox")
  • Enter the full path to your browser in the Location field
  • Don't worry about the working directory
  • Click the Variables button; in the dialog that pops up, look for the variable called "selected_resource_loc". Choose it and dismiss the popup dialog.
  • And now hit "Apply" and dismiss the main dialog.

Running an External Tool Configuration is a lot like running a Launch Configuration: you can choose from the menus, or use the buttons on the button bar; if you click one of those buttons, it will run the last configuration you selected (on whatever document you're editing).

The important things to note are:

  • you have to have the right path to the browser executable
  • the arguments to the executable will be those in the Arguments text area, which is where the variable we chose ("selected_resource_loc") will appear; if you need more stuff on that command line, put it in the Arguments
  • the "selected_resource_loc" is expanded at execution time to the full path of the currently-selected document

See these docs for more detail.

Ladlestein
Thank you very much. -H
HalukO