diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)


Java SE 6 Tries Smaller Footprint, JavaScript Support

Having just emerged from a public beta process that began in the spring of 2005, and especially now that Java is an open-source project, developers will find little to be surprised about in Sun’s newest Java SE 6, released yesterday. But one sign that even Java is adapting with the times – besides its smaller size, which early adopters are applauding – is its new support for external scripting engines, which adopters might not be aware of.

For the first time, Java is “aware” of the presence of scripting languages, including JavaScript – which recently became part of the Java bundle. With scripting languages like Asynchronous JavaScript (AJAX) rapidly becoming common in the creation of browser-based front ends, Java SE 6’s new recognition for scripting engines like JavaScript that follow a standard API to provide scriptable, server-driven functionality.

It could change the architecture of Java-based applications going forward, from nuggets of self-contained programs to distributed systems that use Java for the engine, and JavaScript for the user console. (Sun did not develop JavaScript initially; Netscape did, and it’s successor company Mozilla’s JavaScript engine that is being bundled with the new Java.)

Early snippets of JavaScript-supporting Java source code reveal a typically simple mechanism behind this otherwise aesthetically asynchronous concept. First, a newly declared variable of class ScriptEngineManager instantiates an instance of Java’s new manager function.

From there, another variable is set to point to a handle of the first active script engine it sees in memory. With that handle, JavaScript code (or whatever the native code for the engine may be) is passed a string by way of the eval method; the script engine treats this as though it were being invoked immediately, as through a command line. Java’s exception handling mechanism can then catch any errors.

Alternately, the script engine can be set to point to an existing .JS file by declaring a variable of class FileInputStream, with the filename as the sole argument. Some Java developers may have just read the only documentation they’ll ever need on the subject – it’s literally that simple.
Continue for more info….

Java SE 6 Tries Smaller Footprint, JavaScript Support, Java

Share This Story, Choose Your Platform!