The highly anticipated release of the first beta edition of JDK 1.3 (codename Kestrel) offers developers an expanded API with greatly enhanced functionality. Developers will be impressed with new methods, classes and entire packages, as well as numerous bug fixes across the gamut of the Java API.
The first release of JDK 1.3 is now available for developers, through Sun Microsystem’s Java Developer Connection program. Registration is free, and developers can download both the documentation and SDK for Solaris and Windows. For more information, visit the Java Developer Connection at http://java.sun.com/jdc/.
A wide range of features have been added to the Java API, in the form of new methods, classes, and even entire packages. I’ll go through package by package, highlighting the major changes.
Language and utility enhancements
A new Timer class, for performing background operations at fixed intervals, has been added to the
package, along with
, to represent tasks performed by a timer. However, the name may clash with
. If you import both the
packages, you should explicitly state which
class to which you are referring. This will help to prevent confusion when reading code, and also to prevent a compile-time error.
The Java 2 Platform Standard Edition Version 1.3 represents a significant advance in terms of functionality.
For those working with complex mathematical operations, you may be surprised to find some changes running under JDK 1.3. That’s because
has been substituted for an optimized class that offers performance enhancements, at the cost of some precision. For those who require backwards compatibility, references to
can be replaced with
This can cause problems, however, as
is not available on versions prior to JDK 1.3.
Another important addition is support for system shutdowns and JVM termination. Applications can register a shutdown hook, which is called when the JVM terminates. This allows cleanup operations to be performed, such as closing open files, deleting temporary files, and closing network connections. Shutdown hooks run as separate threads, and can be registered via
, and de-registered by
. If, for some reason, code needs to terminate without shutting down, the
method shuts down the JVM. The use of this method should be avoided wherever possible, however, as applications will be unable to clean up after themselves.
AWT & Swing enhancements
Several modifications have been made to the AWT API, including the introduction of a new class which allows automated testing of AWT components.
has methods to prepare screen captures and generate keystroke or mouse events, as well as to delay user events. Basically, it gives application developers a way to programmatically control user input events, which has wider implications that just testing.
Another welcome change for developers that rely on the Java Print package (
) is the addition of two classes for finer control over printing. The first,
, makes it possible to control details like number of copies, page ranges, and the type of print dialog that is displayed. The second class,
, controls page orientation, page size, page color (monochrome or color), and resolution.
There’s also support for multiple monitors, with the introduction of two new constructors to Window and Frame, that take a GraphicsConfiguration instance as a parameter. There’s also support for the Portable Network Graphics Format (PNG), and numerous method changes to the Swing API. This edition of the Java 2 Platform offers some very cool features that are sure to delight GUI programmers.
For network and distributed systems programmers, there are some useful new features. Several new methods have been added to java.net.Socket, which provide support for half-closed sockets, and the ability to modify the TCP keepalive socket option.
— closes a socket’s input stream, and discards any further data sent from the remote socket
— closes a socket’s output stream, in the same manner as
— returns true if the keepalive socket option is set
setKeepAlive ( boolean )
— turns on, or turns off, the keepalive timer
For those unfamiliar with the intricacies of the transmission control protocol, the keepalive timer checks to see if data is flowing between two sockets, and disconnects if the remote socket is unavailable (such as when a machine is rebooted, or the network is down).
There’s also plenty of enhancements for those interested in distributed systems programming. For a start, the Java Naming and Directory Interface (JNDI), which previously was a standard extension, is now part of the Java 2 platform (see the
packages for more details). Remote Method Invocation (RMI) support has been improved, with support for the Internet Inter-ORB Protocol (IIOP), which means RMI can be used to communicate with CORBA.
Developers interested in audio will be pleased to see Java Sound support included with the Java 2 Platform. It is now possible to capture, manipulate, and playback audio and MIDI files, with the inclusion of the
packages. Support for the following file-types are offered, an expansion from previous versions:
MIDI (Type 1 & Type 2)
Rich Music Format (RMF)
The ability to capture and process MIDI & audio files, while not every developer’s cup of tea, will certainly be attractive to those wishing to write music recording software in Java. The API documentation also indicates that support for both software and hardware MIDI access is provided. Certainly the MIDI synthesis will be a welcome addition to the Java 2 Platform for music and game developers.
Many bug fixes and feature enhancements have been made, both to the core Java API, the
extentions, as well as the documentation and tools that ship with JDK 1.3. While many of these fixes are minor in nature, or impact on only very specialized applications, quite a large number developers will be pleased to see changes. Of particular interest is that the vast majority of bug fixes are graphically related, with
taking the lead for most fixes, followed by
as a close second. The following graph shows bug fixes by package, based on data provided in Sun’s list for JDK 1.3.
Figure 1. Bug fixes by package
My favorite bug/feature fix is that Java can now load images stored in the Portable Network Graphics (PNG) format, in addition to the existing GIF/JPEG support. Having also experienced problems with unusual behavior in Swing-based applications, I’m pleased to see that so many fixes have been made in this area. Hopefully, this will go a long way towards making the Java 2 Platform more robust and user-friendly.
The Java 2 Platform Standard Edition Version 1.3 represents a significant advance in terms of functionality. However, it should be remembered that at this stage, JDK 1.3 is still in early beta and it will be many months before these new features become standard. While it’s tempting to dive in and use these new classes and methods, remember that few users will have a JDK 1.3 Java Virtual Machine (JVM) installed yet. Nonetheless, it’s important to become familiar with these features now, in preparation for the public release of JDK 1.3.
On a final note, if you’re already using JDK 1.2, you may run into some small problems after installing JDK 1.3. I found that under Windows, an error message was generated when using the JDK 1.2 javac.exe, due to a registry entry. Uninstalling both JDK 1.2 and JDK 1.3, and then reinstalling JDK 1.2 fixed the problem, however.
About the author
David Reilly is a software engineer and freelance technical writer living in Australia. A Sun Certified Java 1.1 Programmer, his research interests include the Java programming language and networking & distributed systems. He can be reached via email at [email protected].
Developer.com features tutorials, news, and how-tos focused on topics relevant to software engineers, web developers, programmers, and product managers of development teams. In addition to covering the most popular programming languages today, we publish reviews and round-ups of developer tools that help devs reduce the time and money spent developing, maintaining, and debugging their applications. This includes coverage of software management systems and project management (PM) software - all aimed at helping to shorten the software development lifecycle (SDL).
Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.