Last week I attended JavaZone 2009, where I was allowed to give a presentation on using the script engine interfaces defined in JSR 223 (Scripting for the Java Platform) to easily add scripting capabilities to Java applications.

For those of you who have no idea what that means, here’s the abstract:

By combining the power of compiled and interpreted languages in the same application, can we get the best of both worlds? Can embedding scripting capabilities in our applications help us develop software that is more flexible and more usable? Can we reduce development time by making volatile and highly fluctuating application logic customizable, dynamic and scriptable? Can we make life easier for ourselves as developers by choosing the right language for the right task at any given time?

This presentation gives an introduction to the concept of scripting engines and how they can be used to add scripting capabilities to real-world applications. We take a closer look at the Java scripting engine API (JSR 223) and popular implementations of the standard. The session includes practical examples and actual code.

Thanks to Tandberg and the JavaZone organizers, the presentation was recorded and is now available for online viewing (requires WMV codec/browser plug-in, I think).

Although the practical examples in the presentation are Java (combined with with JavaScript, Python and Ruby), the general principles of combining compiled and interpreted languages apply to other platforms and architectures as well (i.e. C, C++, C#/.NET and other scripting languages), so you may find it relevant even if you are not working in a Java environment.

As promised, I have also uploaded the presentation slides and example source code for your convenience. To run the examples you will need JRuby and Jython, and possibly the JSR 223 engines, depending on which versions of Jython and JRuby you have. (Jython 2.5.1 rc2 includes a working JSR 223 engine, JRuby 1.3.x doesn’t have it, but it looks like JRuby 1.4 will.) Also note that you have to edit the build-*.bat and run-*.bat files to reflect your environment if you want to use them for running and building the examples.