Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Setting up Run Configuration for HTML/Javascript Files

Tags:

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?

like image 520
HalukO Avatar asked Oct 08 '10 17:10

HalukO


People also ask

Can Eclipse run JavaScript?

With this set of good old features added to a more powerful and nicer edition and debug of Web files, the Eclipse IDE now shine again as a great ready-to-use IDE for Web and JavaScript development. It can now be considered for many use-cases by Web or Node. js developer as a viable or better alternative to other IDEs.

How do I view JavaScript files in Eclipse?

Go to the Outline view. If it is not displayed, go to Window | Show View | Outline. on the Outline view's toolbar and select html. HTML and JavaScript objects contained within the file will be displayed in a tree view.


1 Answers

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 along with the executable name of the browser.
  • 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.

like image 181
Ladlestein Avatar answered Sep 29 '22 20:09

Ladlestein