Running javascript from Eclipse

   In this article I will demonstrate how to easily run javascript files from within the Eclipse IDE using Mozilla's Rhino javascript engine. 
   First off download the latest version of the Rhino downloads archive (for this demonstration I will be using Rhino 1.7R4 and Eclipse 4.2 - Juno). Unzip the downloaded archive to an appropriate location. From the Eclipse IDE create a new external configuration (Run -> External Tools -> External Tools Configurations) as follows: 


 1. Click on the Program button.
 2. Click on the New launch configuration button.
 3. Give a sample name on the run configuration (e.g. rhino_javascript). 
 4. Specify the path to java.exe from the java runtime installation directory (assuming java 6 is  already installed on your machine)
 5. For the working directory specify the directory where the Rhino installation arhive is unzipped (it should contain the js.jar file)
 6. For the program arguments specify:

       jar -js ${resource_loc}

    This means that we will be executing the Rhino console against the currently selected file in Eclipse (should be a javascript file).
Now when you have selected a javascript file (e.g. from the Package explorer) you can execute it by running the already created external configuration:

That's it! Have a nice javascripting under Eclipse :)