开发者

Eclipse: Setting up Run Configuration for HTML/Javascript Files

开发者 https://www.devze.com 2023-01-19 19:11 出处:网络
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.

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?


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.


had the same problem, it's really annoying that there is no default behaviour of eclipse to deal with html files.

here is how i did it with pictures! ;)

http://dwaves.de/index.php/2014/01/16/eclipse-run-launch-html-htm-webpage-in-external-browser-external-tools-shortcut-hotkey/


You could install the WTP tools and set up a Static Web Project. Copy your files into that (or you may be able to set up a short cut, I'm not sure). You can change the browser in Preferences->General->Web Browser. Selecting Run with launch the browser and your content.

Eclipse has great refactoring, syntax checking and formatting now for JavaScript, I really recommend it.


I have installed aptana studio plugin for eclipse, and that will enable run as "java script web applicaiton" option.

Install aptana studio pluging as follows


  1. Open Eclipse
  2. Help -> Install New Software
  3. Add (on the top right)
  4. Enter the following link for Aptana Plugin with
  5. http://download.aptana.com/studio3/plugin/install
  6. Click OK
  7. Put a check mark for Aptana Studio 3
  8. finish

install wamp server if you dont have it http://www.wampserver.com/


Go to the Main Menu with in the Select --> window -> webbrowser --> Here by default "internal browser will selcted" if you want to change select --> chrome/firefox/ie then you can run the web application project and the result will be displayed in the web browser you selected.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号