he latest work-in-progress release of Java Standard Edition (Java SE) version 6.0 (code-named Mustang) offers a smorgasbord of improvements that will change how developers deal with security, JMX, OS files, internationalization, and desktop development in their Java applications. (Read Eric Bruno's article "Java SE 6 First Impressions: A Desktop Winner
" to learn all the goodies in store.) Sun Microsystems took a very collaborative approach in developing the specification for this release and it shows. By listening to developers via JSR 270 (the umbrella Java Specification Request for the Java SE 6 release) and releasing the entire Java SE 6 source and binaries beginning in early February 2006, Sun has been able to cull quite a buffet of tantalizing new features.
Mustang's desktop-integration capabilities particularly are something many Java developers have been clamoring for in previous releases. These new features bring a lot of fun to Java desktop application development. Those who have developed Java applications that required interaction with desktop products and features such as Internet Explorer, system tray, and mail clients had to contend with clamp-on contraptions such as JTray and SysTray or venture into the hard-hat area of Java Native Interface (JNI). While this patchwork of solutions served its purpose, any developer with an eye for elegance wanted these features to be part of the core Java platform.
This article steps through the creation of an application called GoMustang that launches with a splash screen and then becomes available on the system tray for one-click browser access to DevX.com. Along the way, it demonstrates how to use Java SE 6 to show a splash screen when an application launches, how to create a system tray icon, and how to launch the native desktop Internet browser from within Java.
Get Your Own Horse
First, download the Java SE 6 Beta
from Sun's Java Web site. As of March 1, Java SE 6 Beta-b59 was the as-stable-as-it-can-be-for-now version. While Sun has set a target date of Fall 2006 for final release and some features are subject to change based on the recommendations of the JSR 270 Expert Group, it's not too early to take Mustang for a ride (pun intended) in your desktop development.
The features described in this article should not change much, so you may want to get the most recent downloads of the JDK, JRE, and documentation. For the more adventurous types, snapshot downloads also are available.
Before you moving on, ensure that your desktop platform is supported. I developed and tested the application on Windows XP with no problems.
Once downloaded, go through the regular drill and install both the JDK and JRE. The installation defaults to the JDK and JRE install directories at c:\program files\java\jdk1.6.0 and c:\program files\java\jre1.6.0, respectively. For sake of simplicity, stick to the default installation settings.
Make sure your computer's Environment Variables in the Windows System Properties are pointing to the Java SE 6.0 JDK. I had JAVA_HOME Environment Variable
JAVA_HOME= C:\Program Files\Java\jdk1.6.0.
Once you have your installation complete, check the version of the Java JRE. You should receive a message that indicates 1.6.0-beta, as follows:
C:\java\mustang> java -version
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59g)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59g, mixed mode, sharing)