About the Examples
Most methods and classes described in this book are illustrated with
at least one complete working program, simple though it may be. In my
experience, a complete working program is essential to showing the
proper use of a method. Without a program, it is too easy to drop
into jargon or to gloss over points about which the author may be
unclear in his own mind. The Java API documentation itself often
suffers from excessively terse descriptions of the method calls. In
this book, I have tried to err on the side of providing too much
explication rather than too little. If a point is obvious to you,
feel free to skip over it. You do not need to type in and run every
example in this book, but if a particular method does give you
trouble, you are guaranteed to have at least one working example.
Each chapter includes at least one (and often several) more complex
programs that demonstrate the classes and methods of that chapter in
a more realistic setting. These often rely on Java features not
discussed in this book. Indeed, in many of the programs, the
networking components are only a small fraction of the source code
and often the least difficult parts. Nonetheless, none of these
programs could be written as easily in languages that
didn't give networking the central position it
occupies in Java. The apparent simplicity of the networked sections
of the code reflects the extent to which networking has been made a
core feature of Java, and not any triviality of the program itself.
All example programs presented in this book are available online,
often with corrections and additions. You can download the source
code from http://www.cafeaulait.org/books/jnp3/.
This book assumes you are using Sun's Java
Development Kit. I have tested all the examples on Linux and many on
Windows and MacOS X. Almost all the examples given here
should work on other platforms and with other
compilers and virtual machines that support Java 1.2 (and most on
Java 1.1, as well). The occasional examples that require Java 1.3,
1.4, or 1.5 are clearly noted.