Running with Mustang

Lee Chuk-Munn reviews the features in JavaSE 6, the JDK formerly known as Mustang.

Over the past nine months or so, I have been introducing some of the new and compelling features in JavaSE 6, the JDK formerly known as Mustang. Now that JDK 6 has been officially released, let's reiterate what some of these features are:

1. Scripting support (part 1, part 2) Scripting support (JSR-223) allows Java developers to invoke scripts (and functions) from within a Java application. The support is not one way only; you can also invoke Java applications or use Java libraries, like Swing, from within a script. In fact, JavaSE 6 can support any scripting engine that is JSR-223 compliant. You can find a list of these engines on

2. Annotations and annotation processing (part 1, part 2, part 3, part 4) Annotations have greatly simplified the way we develop Java applications. What are annotations? In a nutshell, you can think of annotations as comments for programs. When we compile a class that is marked by the @WebService annotation, the compiler will generate the boilerplate code that will allow that class to be deployed as a Web service. JavaSE 6, will for the first time allow developers to write standard complaint (JSR-269) annotations processors to process your own custom annotations.

3. Desktop enhancements (tray icon, splash screen, tab panels) Java is undergoing a resurgence on the desktop; JavaSE 6 delivers a lot of features that allow developers to develop desktop applications that are richer and more tightly integrated to the desktop. Chief among these is tray icons; tray icons are programs that sit on your desktop's system tray. Creating splash screens is also easier with JavaSE 6. If you want to add a splash screen to your application, even an old desktop application, just start your application like so:

java -splash an_image_file.png Your.Java.Application

4. Web services (part 1, part 2) Web services have always been developed and deployed in a JavaEE environment. JavaSE 6 brought Web services to the desktop by bundling a standard set of Web services APIs. Developers are now able to develop desktop based applications that not only can consume a Web service, but can also publish Web services without having to install a JavaEE server!

5. Monitoring and management (part 1, part 2, part 3, part 4) JMX (Java Management Extension) has been a standard part of JavaSE 5 platform. Using JMX, you are able to peer into your Java application at runtime, and find out the memory that it is consuming, the number of threads, CLASSPATH settings, etc. JavaSE 6 makes monitoring your application even easier with its attach-on-demand JMX agents and better tools (jconsole).

6. Services lookup (services) Services lookup allows you to find all implementations on your CLASSPATH to a particular Java interface.

There are also other noteworthy features that I've not covered. Here is a list of them:

1. Classpath wildcards (article) If you have multiple JARs under the lib directory for example, to set the CLASSPATH, you have to individually specify all the JARs like so


Now using classpath wildcards, the above setting can be shorten to


2. Console API (a href="" target="_blank">link) Console API allows you to access the text console.

3. DTrace support (link) JMX allows you to only observe a Java application down to the JVM level. However if you wish to tune your Java application right down to the operating system, you will have to turn to dynamic tracing (DTrace). DTrace allows you to observe an interaction right down into the operating system level. If a Java application opens a file, using DTrace, we can find the system call that is used and on which hard disk the file is located. DTrace is currently only supported on the Solaris 10 operating systems.

What are you waiting for; download JavaSE 6 and try it out!

Lee Chuk-Munn has been programming in the Java language since 1996, when he first joined Sun Microsystems in Hong Kong. He currently works as a senior developer consultant and technology evangelist for Technology Outreach at Sun in Singapore. Chuk's focus is in Java APIs, Java EE, Java SE, and Java ME. Chuk graduated in 1987 from the Royal Melbourne Institute of Technology in Melbourne, Australia, where his favorite subject was compiler theory.