advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the Code!
Partners & Affiliates
advertisement
advertisement
Average Rating: 4/5 | Rate this item | 1 user has rated this item.
 Print Print
 
Dynamic Scripting Lands in Europa: A Profile of Eclipse Monkey
Bring the power of JavaScript into your Eclipse workspace and learn how to make the most of it. 

advertisement
he recent Eclipse Europa release is the culmination of coordinated efforts between a number of Eclipse subprojects. Its major components, such as the Java Development Tools (JDT) and Web Tools Platform (WTP), garner a majority of the interest, but many other Europa projects are worth a try. This article introduces just such an under-the-radar project: Eclipse Monkey, a tool for creating, using, and sharing interpreted scripts (in the JavaScript programming language) that interact with the Eclipse platform.


Don't confuse Eclipse Monkey with the Eclipse Dynamic Languages Toolkit (DLTK) project. The former integrates user-created JavaScript that enrich platform capabilities; the latter extends the set of programming languages supported by the platform with new editors, debuggers, and other development tools.

Eclipse Monkey relies on the Mozilla Rhino JavaScript engine to evaluate scripts. This is the same engine that powers the Firefox web browser and ships with Java SE 6 as an implementation of the JSR-223 specifications for scripting engines (Rhino permits interoperation between scripts and the Java environment in which the scripts run.). So developers can leverage the JavaScript skills they gained from writing scripts either for the web or within Java SE 6 applications to create Monkey scripts.

Get Started
The first step in using Eclipse Monkey is installation. This is a straightforward process:

  1. Open the Update Manger.
  2. Search for new features to install on the Europa Discovery Site.
  3. Choose the Monkey project.

The Update Manager also installs the Mozilla Rhino JavaScript engine, on which Eclipse Monkey depends.

After the installation finishes, you are ready to test your first script:

  1. Create a new project.
  2. Create a folder named scripts.
  3. Create the following "Hello World" script inside the scripts folder and call it test.js:
    
    /*
     * Menu: Simple > Hello world
     */
    function main() {
    	Packages.org.eclipse.jface.dialogs.MessageDialog.openInformation( 	
    	window.getShell(), 	
    	"Message", 
    	"Hello world!");	
    }
    

On the menu bar, a new entry appears inside the Scripts menu. It points to your just created script. When you click it, a dialogs pops up with the classic hello world message.

Behind the Scenes
The "Hello World" script uses the Packages prefix to access the MessageDialog Java class available within the Eclipse platform and to invoke the static openInformation() method on it. This is the standard method that Eclipse components use to open a message dialog box. The Packages object is a Rhino-specific feature (as described in its official documentation) that provides the bridging capabilities between Java and JavaScript.

JavaScript is the only language that Eclipse Monkey supports out of the box, but you can contribute additional ones by using the org.eclipse.eclipsemonkey.language extension point and following the standard practice for creating additional components for the Eclipse platform. This extension point describes the interfaces to implement for integrating an additional language with Monkey.

However, keep in mind that Eclipse Monkey is not JSR-223 aware; you cannot plug in support for other scripting languages in the same way you do in a standard Java application based on Java SE 6. That is, you cannot provide new scripting engines by using the interfaces exposed in the javax.script packages. If you are interested in this kind of scripting support for Eclipse (e.g., plug-ins and extensions in interpreted languages such as Ruby), refer to my previous DevX article on the subject.

Page 1 of 3


advertisement
  Next Page: Scripts Metadata and DOMs
Page 1: IntroductionPage 3: "Shareability"
Page 2: Scripts Metadata and DOMs 
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES