Java Versions

Java’s network classes have changed much more slowly since Java 1.0 than other parts of the core API. In comparison to the AWT or I/O, there have been almost no changes and only a few additions. Of course, all network programs make extensive use of the I/O classes, and many make heavy use of GUIs. This book is written with the assumption that you and your customers are using at least Java 1.1 (an assumption that may finally become safe in 2001). In general, I use Java 1.1 features such as readers and writers and the new event model freely without further explanation.

Java 2 is a bit more of a stretch. Although I wrote almost all of this book using Java 2, and although Java 2 has been available on Windows and Solaris for more than a year, no Java 2 runtime or development environment is yet available for the Mac. While Java 2 has gradually made its way onto most Unix platforms, including Linux, it is almost certain that neither Apple nor Sun will ever port any version of Java 2 to MacOS 9.x or earlier, thus effectively locking out 100% of the current Mac installed base from future developments. ( Java 2 will probably appear on MacOS X sometime in 2001.) This is not a good thing for a language that claims to be “write once, run anywhere”. Furthermore, Microsoft’s Java virtual machine supports only Java 1.1 and does not seem likely to improve in this respect the foreseeable future (the settlement of various lawsuits perhaps withstanding). Finally, almost all currently installed browsers, including Internet Explorer 5.5 and earlier and Netscape Navigator 4.7 and earlier, support only Java 1.1. Applet developers are pretty much limited to Java 1.1 by the capabilities of their customers. Consequently, Java 2 seems likely to be restricted to standalone applications on Windows and Unix for at least the near term. Thus, while I have not shied away from using Java 2-specific features where they seemed useful or convenient—for instance, the ASCII encoding for the InputStreamReader and the keytool program—I have been careful to point out my use of such features. Where 1.1-safe alternatives exist, they are noted. When a particular method or class is new in Java 1.2 or later, it is noted by a comment following its declaration like this:

public void setTimeToLive(int ttl) throws IOException // Java 1.2

To further muddy the waters, there are multiple versions of Java 2. At the time this book was completed, the current release was the Java™ 2 SDK, Standard Edition, v1.2.2. At least that’s what it was called then. Sun seems to change names at the drop of a marketing consultant. In previous incarnations, this is what was simply known as the JDK. Sun also makes available the Java™ 2 Platform, Enterprise Edition ( J2EE™) and Java™ 2 Platform, Micro Edition ( J2ME™). The Enterprise Edition is a superset of the Standard Edition that adds features such as the Java Naming and Directory Interface and the JavaMail API that provide high-level APIs for distributed applications. Some of these additional APIs are also available as extensions to the Standard Edition, and will be so treated here. The Micro Edition is a subset of the Standard Edition targeted at cell phones, set-top boxes and other memory, CPU, and display-challenged devices. It removes a lot of the GUI APIs that programmers have learned to associate with Java, though surprisingly it retains almost all of the basic networking and I/O classes discussed in this book. Finally, when this book was about half complete, Sun released a beta of the Java™ 2 SDK, Standard Edition, v1.3. This added a few pieces to the networking API, but left most of the existing API untouched. Over the next few months, Sun released several more betas of JDK 1.3. The finishing touches were placed in this book, and all the code was tested with the final release of JDK 1.3.

To be honest, the most annoying problem with all these different versions and editions was not the rewriting they necessitated. It was figuring out how to identify them in the text. I simply refuse to write Java™ 2 SDK, Standard Edition, v1.3, or even Java 2 1.3 every time I want to point out a new feature in the latest release of Java. Consequently, I’ve adopted the following convention:

  • Java 1.0 refers to all versions of Java that more or less implement the Java API as defined in Sun’s Java Development Kit 1.0.2.

  • Java 1.1 refers to all versions of Java that more or less implement the Java API as defined in any version of Sun’s Java Development Kit 1.1.x. This includes third-party efforts such as Macintosh Runtime for Java (MRJ) 2.0, 2.1, and 2.2.

  • Java 1.2 refers to all versions of Java that more or less implement the Java API as defined in the Standard Edition of Sun’s Java Development Kit 1.2.x. This does not include the Enterprise Edition additions, which will be treated as extensions to the standard. These normally come in the javax package rather than the java packages.

  • Java 1.3 refers to all versions of Java that more or less implement the Java API as defined in the Standard Edition of Sun’s Java Development Kit 1.3.

In short, this book covers the state-of-the-art for network programming in Java 2, which isn’t really all that different from network programming in Java 1.1. I’ll post updates and corrections on my web site at http://metalab.unc.edu/javafaq/books/jnp2e/ as more information becomes available. However, the networking API seems fairly stable.

Get Java Network Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.