he recently released Java Standard Edition 6 (Java SE 6, a.k.a. Mustang) beta is feature complete and stable enough for mainstream evaluation. I downloaded and test drove the release in its first week of availability and came away particularly impressed with the new desktop features. Besides sporting the new naming convention for all Java platforms (the “2” has been dropped), it has been improved with many new features that are worth exploring. The improvements can be broken down into two categories: desktop and core.
The desktop improvements focus mainly on user interface (UI) performance and native OS desktop integration. The core improvements focus mainly on improving developer productivity and Java application management. Sun’s Mustang team also put significant effort towards Web services support and security improvements.
Overall, whether you’re an application developer, a system administrator, a tool vendor, or a security expert, Java SE 6 has something for you. This article presents some of the interesting new features I used in some more detail.
Core Features and Improvements
The Java core can be described as portions of Java (the language and its tools) that are fundamental to all other aspects of Java, from user interface APIs to server libraries. I describe the improvements to the Java core in Java SE 6 here, broken down by sub-category.
The new Java Compiler API allows Java source to be compiled from within a Java application. During compilation, the application has access to the library dependency information as formulated, along with any warnings, errors, and other messages that are generated. Although this feature did not seem like something I would use often, I quickly found new uses for it. For instance, I used it to quickly build the data-access layer for an application I had been building. The code I wrote generated and compiled the classes used to access the application’s database tables. The end result was a JAR file that was generated, built, and deployed as part of the system’s Ant scripts. The fact that the classes are compiled from within the application makes the code generation interactive?I can modify and build the classes iteratively.
To enable Java scripting, Java SE 6 supports JSR 223, a scripting framework that provides scripting language access to Java internals. You can locate scripting engines and invoke them to run scripts at runtime. The Scripting API allows you to provide Java support for the scripting language of your choice. In addition, the Web Scripting Framework allows script code to generate Web content within any Servlet container.
For debugging, the Java Platform Debugger (JPDA) has been enhanced to detect deadlocks and generate stack traces for monitor objects that are locked. In addition, Java SE 6 adds support to allow agents to attach to a running JVM for diagnostic purposes.
Java SE 6 enhances memory leak analysis and detection by including a full stack trace in the java.lang.OutOfMemory exception and generating a fatal error log when the heap is full. In addition, a new JVM option allows you to run a script when the heap is full.
Improvements to the JMX Monitoring API allow an application to send events when MBean attribute values (including those within complex types) pass specified thresholds.
For Solaris 10 users, the Hotspot JVM for Solaris provides hooks for the Solaris DTrace system debugging utility to track and display internal JVM activities, such as garbage collections, class loading, threads, locks, and so on. I was given a demo of this feature first-hand at JavaOne and was very impressed by the depth of debugging the DTrace system provides. As an application runs, DTrace allows you to stop the code anywhere, view all of the libraries loaded (not just the Java libraries, but all system libraries), and step right into the Solaris kernel?down to the hardware. Java’s new support for this amazing tool makes available the world of system debugging. I can recall some times in the past when I received Solaris Signal-8 errors in the JVM; this feature would have saved me a lot of guessing.
Java SE 6 includes a few APIs to support Web services. The XML Digital Signatures API allows you to secure Java-based Web services by performing cryptographic operations on XML data. The Java-XML Web Service (JAX-WS) 2.0 API updates the library formerly named JAX-RPC. Improvements to Java-XML Binding (JAXB) 2.0 include XML schema support and class binding to a schema. Lastly, the Streaming API for XML (STaX) provides a bi-directional API to read and write XML via a stream of events, including the ability to skip sections, and focus on sub-sections of documents.
Java SE 6’s security offerings include GSS/Kerberos integration, Java Authentication and Authorization Service (JAAS) for LDAP authentication, and a security certificate request framework that allows Java applications to request secure certificates over a number of protocols.
Desktop Features and Improvements
Java has long been regarded as an excellent language for server-based software, but as second-rate for desktop GUI applications. The Java desktop team at Sun has been working to change this perception by integrating Java more closely with the host system it runs on. The result is not only improved GUI performance in Java SE 6, but also improvements in the behavior of Java GUI applications.
Many of the new desktop features in Java SE 6 are based on the JDesktop Integration Components (JDIC) project. The JDIC project gives Java applications access to features available on the native OS desktop, such as the browser, email editor, file-type associations, the system tray, application launching, and printing. The following are some of the more prominent Java desktop improvements in Java SE 6:
- Splash screen support?Splash screens inform a user that an application is starting while he waits. Java SE 6 adds support for splash screens that can be displayed even before the JVM starts.
- Java Foundation Classes (JFC) and Swing Improvements:
- Java SE 6 leverages Windows APIs to both improve performance and ensure the Windows look-and-feel on current and future versions of Windows.
- It improves layout management to include customizable layout managers and includes other enhancements to simplify GUI component layout.
- It has vastly improved Swing drag-and-drop, making it customizable.
- True double-buffering provides quick, smooth graphic transitions.
- System Tray Support?Two new classes, SystemTray and TrayIcon, in the java.awt package allow you to add icons, tool tips, and pop-up menus to the Windows or Gnome Linux system tray. The system tray is the desktop area shared by all applications, usually located in the lower-right corner. Actions and events allow your Java application to track mouse clicks on the items you place in the tray, and respond to those clicks. I have found this feature useful for my server applications as well. For instance, used with the Desktop API (see below), I now add an icon to the system tray to easily launch a browser for the application’s administrative HTML page. Regardless of OS (Linux or Windows), I no longer need to recall the application’s administrative port or URL?simply click the icon and the page appears.
- Improved print support for JTable
- Java 2D enhancements?Improvements have been made to text display quality, especially on LCD monitors. Integration with the host desktop’s font anti-aliasing settings ensures consistent text rendering.
- The new java.awt.Desktop API?The new Java SE 6 Desktop package aims to make Java UI applications “first-class citizens.” With this package, Java applications can launch the default browser and email client, and integrate with common desktop applications (such as OpenOffice) to open, edit, and print files of specific types. The Desktop package offers this ability through action events (Desktop.Action) that you can integrate into your applications.
- Internationalization?Java SE 6 supports “plugability” for some locale-specific features, such as date formatting, Unicode text normalization, and resource bundles.
A Java Desktop Revolution
While Java SE 6 provides too many individual feature additions, improvements, and bug fixes to be listed here, this article provides a roadmap to this upcoming, important, Java release. The improvements span so many aspects of the standard edition of Java that all stakeholders will be affected, including those intimate with Java Enterprise Edition.
Java SE 6 has the potential to be as revolutionary to the desktop as Java 2 was to the server. It’s best to be prepared for this storm now, and position yourself to cash in on the potential rewards available to the early adopters.