O'Reilly logo

Java Cookbook by Ian F. Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Platform Notes

In its short history, Java has gone through four major versions. The first official release is known as Java JDK 1.0, and its last bug-fixed version is 1.0.2. The second major release is Java JDK 1.1, and the latest bug-fixed version is 1.1.9, though it may be up from that by the time you read this book. The third major release, in December 1998, was to be known as Java JDK 1.2, but the Sun marketing gremlins abruptly renamed JDK 1.2 at the time of its release to Java 2, and the implementation is known as Java SDK 1.2. The current version as of this writing is Java 2 SDK 1.3 (JDK 1.3), which was released in 2000. Around the same time, two other packages, one low-end and one high-end, were announced. At the low end, Java Micro Edition (JME) is designed for tiny devices, such as Palm computers, telephones, and the like. At the high end, the Java 2 Enterprise Edition (J2EE) extends Java 2 by adding additional features for enterprise or large-scale distributed commercial applications. One of the key features of the Enterprise Edition is Enterprise JavaBeans™ (EJB). EJB has little in common with client-side JavaBeans except the name. Many Java pundits (including myself) believe that EJB will become a significant player in the development of large commercial applications, perhaps the most significant development of this era.

As we go to press, Java 2 Version 1.4 is about to appear. It entered beta (which Sun calls “early access”) around the time of the book’s completion, so I can only mention it briefly. You should cast your sights on http://java.sun.com to see what’s new in 1.4 and how it affects the programs in the book.

This book is aimed at the Java 2 platform. By the time of publication, I expect that all Java implementations will be fairly close to conforming to the Java 2 specification. I have used four platforms to test this code for portability. The official “reference platform” is Sun’s Java 2 Solaris Reference Implementation, which I used on a Sun SPARCStation running Solaris. To give a second Unix flavor, I’ve tested with Kaffe[1] and with Sun’s Linux JDK running under the OpenBSD Unix-like system. For the mass market, I’ve used Sun’s Java 2 Win32 (Windows 95/98/NT) implementation. And, “for the rest of us,” I’ve run some of the programs on Apple’s MacOS Runtime for Java (MRJ) running under MacOS 8 on a Power Macintosh and a few on MacOS X (which Apple wants you to pronounce “Oh Ess Ten,” despite the way they’ve been writing it for the last three years). However, since Java is portable, I anticipate that the examples will work on MacOS X except where extra APIs are required. Not every example has been tested on every platform, but all have been tested on at least one, and most on more than one.

The Java API consists of two parts, core APIs and non-core APIs. The core is, by definition, what’s included in the JDK that you download for free from http://java.sun.com. Non-core is everything else. But even this “core” is far from tiny: it weighs in at around 50 packages and well over a thousand public classes, each with up to 30 or more public methods. Programs that stick to this core API are reasonably assured of portability to any Java 2 platform.

The non-core APIs are further divided into standard extensions and non-standard extensions. All standard extensions have package names beginning with javax.,[2] and reference implementations are available from Sun. A Java licensee (like, say, Apple or Microsoft) is not required to implement every standard extension, but if they do, the interface of the standard extension should be adhered to. This book will call your attention to any code that depends on a standard extension. There is little code that depends on non-standard extensions other than code listed in the book itself (the major exception is the Regular Expressions API used in Chapter 4). My own package, com.darwinsys.util, contains some utility classes used here and there; you will see an import for this at the top of any file that uses classes from it.

[1] Kaffe, the Swedish word for coffee, is an open source (GNU Public License) Java implementation that runs on just about any Unix or Unix-like system, and has been ported to other platforms such as Win32.

[2] Note that not all packages named javax. are extensions: javax.swing and its sub-packages -- the Swing GUI packages -- used to be extensions, but are now core.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required