Scripting in Java 6.0

by Krishna Srinivasan

I have written one small program on how to execute scripts in Java 6.0


In this article i will write a small program using Scripting feature in Java 6.0, a new feature introduced in Java 6.0 mustang. This is cool and more useful when we are working with the scripting languages. I am not going to explain in depth, will explain with very small example. In my next article i will write about the advanced features in script programming in java. Follow the steps to run your first script program in Java 6.0 :

Java Scripting in Java 6.0 (Mustang) - Article
Spring Resources and Articles
Struts Tutorials and Articles


2006-12-15 03:13:26
This method looks just like normal invocation of Rhino engine.
What are the differences?
2006-12-15 07:43:32
I am relatively new to the concept of scripting like your article describes. After reading it I wonder why in the world people would want to do that as opposed to just sticking with plain old Java?
George Jempty
2006-12-15 11:39:25
By way of answering Aaron, one reason why somebody would want to incorporate scripting into their Java app(s) might be when some data to be reckoned with is in a format that is native to a particular scripting language. An example of this is JSON: "Javascript Object Notation". Valid JSON constitutes a valid Javascript "object literal" (and by the way is probably the preferred format for returning data from the misnamed AJAX/XMLHttpRequest), and if you incorporate the Rhino/Javascript engine into your application, you might be able to deal more efficiently with JSON data.
2006-12-15 14:35:05
One example of scripting with a VM that I like is as a replacement for large XML descriptors. A lot of XML we write is basically a type of interpreted language, we might as well go all the way. Consider for example that .bashrc is configuration, in the format of a script. Instead of writing a parser, and a file format, you just use bash to configure your bash shell.

Another example I heard at JavaOne some years back was a script terminal that allowes you to inspect/change runtime values in an app server. It'd be a bit like changing your unix shell, but instead you're changing the way a running VM is configured.

But aside from that, the Ruby/rails, php, and Python sites demonstrate that scripting has advantages. Not many of the 'famous' web 2.0 sites are java.

Kazushi Sakuraba
2006-12-17 04:43:20
Is there even one? Youtube is written in Phyton for example.

(Not that Im saying that youtube needs distributed transactions, but you get the idea)