Java Versions

Java's network classes have changed a lot 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 tutorial is written with the assumption that you and your customers are using at least Java 1.1. In general, I use Java 1.1 features like 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 this entire tutorial using Java 2, and although Java 2 has been available for most platforms for several years, no Java 2 runtime or development environment is yet available for MacOS 9. It is virtually certain that neither Apple nor Sun will ever port any version of Java 2 to MacOS 9.x or earlier, thus effectively locking out 60% of the current Mac-installed base from future developments. This is not a good thing for a language that claims to be "write once, run anywhere." Furthermore, Microsoft's Java virtual machine supports Java 1.1 only and does not seem likely to improve in this respect for the foreseeable future. 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 tutorial was completed, the current release was the "Java 2 SDK, Standard version, v 1.4.2_05". 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 version (J2EE)" and "Java 2 Platform, Micro version (J2ME)". The Enterprise version is a superset of the standard version that adds features like the Java Naming and Directory Interface and the JavaMail API that provide high-level APIs for distributed apps. Most of these additional APIs are also available as extensions to the standard version, and will be so treated here. The Micro version is a subset of the standard version targeted at cell phones, set-top boxes, and other memory, CPU, and display-challenged devices. It removes a lot of the GUI APIs programmers have learned to associate with Java, although surprisingly it retains many of the basic networking and I/O classes discussed in this tutorial. Finally, when this tutorial was about half complete, Sun released a beta of the "Java 2 SDK, Standard version, v1.5". 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.5. The finishing touches were placed on this tutorial and all the code tested with JDK 1.5 beta 2. You shouldn't have any trouble using this tutorial after 1.5 is released. With any luck at all, discrepancies between the final specification and what I discuss here will be quite minor. To be honest, the most annoying problem with all these different versions and versions 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 version, v1.3 or even Java 2 1.3 every time I want to point out a new feature in the latest release of Java. I normally simply refer to Java 1.1, Java 1.2, Java 1.3, Java 1.4, and Java 1.5. Overall, though, the networking API seems fairly stable. Java 1.1 through Java 1.3 are very similar, and there are a few only major additions in Java 1.4 and 1.5. Very little of the post-1.0 networking API has been deprecated.