Java SE 6 Tries Smaller Footprint, JavaScript Support

By Scott M. Fulton, III | Published December 12, 2006, 9:23 PM

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.

But why do it? Being able to craft an application's front-end functionality in JavaScript by definition means being able to use XHTML for the layout and XML for provisioning to the outside world. Java has historically never had a visually resplendent foundation for user interfaces.

But with JavaScript as a real tool, a Windows developer can craft a front end in XAML that takes full advantage not only of Internet Explorer 7, but also the Windows Foundation Class libraries while retaining a high degree of platform independence. That, and applications' front ends will look a whole lot better.

For those who will be crafting native Java front ends, SE 6 (still known by its loving creators as "Mustang") supports a strengthened windowing foundation class system called Swing. Among other long-desired features, Swing now enables developers to deploy drag-and-drop functionality that's compatible with documents, files, and other objects from outside the realm of Java. Now users will be able to drag items from Windows Explorer into a Java-managed window, and have that window respond using a standard API.

Also in the "At Long Last" category is direct support for Web services, as embodied by the JAX-WS API. While Web services development tools such as Forte and Web Services Developer Pack (WSDP) has been part of Java distributions for several years, what's been missing is a standard means by which Java applications could consume Web services by way of SOAP protocol. For what's called an "endpoint deployment model," clients in a distributed environment are typically thin, relying on server-driven functionality, having clients place multiple requests using an internal HTTP driver.

Until recently, such a driver had not been formalized for Java; and due to security and architectural implications, not all developers had been certain they even wanted one.

With the inclusion of JAX-WS, that argument has been put to rest. The client HTTP driver is there, and developers will have to learn to live with it for the sake of interoperability.

As Java creator James Gosling wrote in an open letter to the Java development community yesterday, "Java technology has been a cornerstone of software development for more than a decade now - the community is ready for the next chapter, and the timing is right...We intend to take steps to help make sure Java technology remains compatible, interoperable, and reliable. And we know the Java community feels the same way."

Comments

View comments by with a score of at least

Java's hey days are over. C# is the rising star.

Java is too rigid and has too much "code noise".

Score: 0

|

Code Noise?
What specifically are you referring to?

Have you programmed in Java before, or are you a MS fanboy? I've done both and C/C++ (on many platforms as well), Java is very good (its not perfect, unsigned types would be a welcome for me), but its no better or worse than C# syntactically. I still don't get why we actually needed C#, but since MS said so, I guess I do :)

Score: 0

|

Yeah, I do Java for a living.

I won't go into the technical details, but here are some of the things that bug me: delegates, closure, properties, generics (Java's generics support isn't as good), checked exceptions, anonymous methods.

C# is like my Java wishes come true.

Score: 0

|

AJAX will play UEFA-cup this evening. If I remember correctly, against Zulte-Waregem.

Score: 0

|

It's also washing power, if you remember it:

http://www.feniweb.ch/wo...4_ajax_logo_150_rgb.jpg

Score: 0

|

That's all good news for me, as I'm currently in the process of learning java (and various other languages) to a degree level.
The more uses there are for it, the more people will want my trade.

Being able to do AJAX with it is very nice.

Score: 0

|

Google Buzz: Another attempt to harness the content firehose

Similar to how Google successfully remolded RSS into a Google tool, the company now wants to remold Gmail into one big Google party

Success: Google's Nexus One shipping support line takes tech support questions

UPDATED Though the support line had been set up for shipping, it now appears Google personnel are happy to hear technical concerns.

Goodnight, moon: What I learned from a space shuttle

Carmi Levy | Wide Angle Zoom: Can the tech sector learn a few lessons from the space program? Certainly, if you believe in learning from someone else's mistakes.

Netflix to FCC: NBCU + Comcast could bypass net neutrality

Weaning itself from the post office as its main means of video transfer, Netflix would like someone to ensure the Internet remains just as unencumbered.

Rhapsody to become an independent company

RealNetworks and Viacom subsidiary MTV Networks have begun the process of spinning off music service Rhapsody into an independent company.

Nvidia debuts new dynamically-switched graphics card technology

Today, Nvidia announced that its Optimus technology for GPU switching will soon be available in a handful of Asus notebooks.

Google lowers 'unusually high' early termination fee on Nexus One

Google has lowered the Nexus One's early termination fees which were twice as high as the norm.

Netgear and Ericsson introduce a mobile broadband hotspot with a twist

It's a mobile broadband hotspot, but it's for use in the home.

Report: Streaming video drove 72% global increase in mobile data consumption

A new study says streaming video is "the single most influential factor driving the need for increased mobile network capacity."

Stymied by continuing Nexus One 3G issues, Google blames the environment

If you're still afflicted with the 3G flip-flop trouble, then you might consider moving. That appears to be the only suggestion Google can give for now.

Wolfram|Alpha makes a strong argument for virtual keyboards

"Answer engine" Wolfram|Alpha has updated its iPhone/iPod Touch app, harnessing the strength of the virtual keyboard.