Java’s growth over the last 20 years has been nothing short of phenomenal. Given Java’s rapid rise to prominence and the even more spectacular growth of the Internet, it’s a little surprising that network programming in Java is still so mysterious to so many. It doesn't have to be. In fact, writing network programs in Java is quite simple, as this book will show. Readers with previous experience in network programming in a Unix, Windows, or Macintosh environment should be pleasantly surprised at how much easier it is to write equivalent programs in Java. The Java core API includes well-designed interfaces to most network features. Indeed, there is very little application layer network software you can write in C or C++ that you can’t write more easily in Java. Java Network Programming endeavors to show you how to take advantage Java’s network class library to quickly and easily write programs that accomplish many common networking tasks. Some of these include:
Java is the first (though no longer the only) language to provide such a powerful cross-platform network library for handling all these diverse tasks. Java Network Programming exposes the power and sophistication of this library. This book’s goal is to enable you to start using Java as a platform for serious network programming. To do so, this book provides a general background in network fundamentals, as well as detailed discussions of Java’s facilities for writing network programs. You’ll learn how to write Java programs that share data across the Internet for games, collaboration, software updates, file transfer, and more. You’ll also get a behind-the-scenes look at HTTP, UDP, TCP/IP, and the other protocols that support the Internet and the Web. When you finish this book, you’ll have the knowledge and the tools to create the next generation of software that takes full advantage of the Internet.
In 1996, in the first edition of this book’s opening chapter, I wrote extensively about the sort of dynamic, distributed network applications I thought Java would make possible. One of the most exciting parts of writing subsequent editions has been seeing virtually all of the applications I foretold come to pass. Programmers are using Java to query database servers, monitor web pages, control telescopes, manage multiplayer games, and more, all by using Java’s native ability to access the Internet. Java in general and network programming in Java in particular has moved well beyond the hype stage and into the realm of real, working applications.
This book has come a long way, too. The fourth edition focuses even more heavily on HTTP and REST. HTTP has gone from being one of many network protocols to almost the network protocol. As you’ll see, it is often the protocol on which other protocols are built, forming its own layer in the network stack.
There have been lots of other small changes and updates throughout the java.net
and supporting packages in Java 6, 7, and 8, and these are covered here as well. New classes addressed in this edition include CookieManager
, CookiePolicy
, CookieStore
, HttpCookie
, SwingWorker
, Executor
, ExecutorService
, AsynchronousSocketChannel
, AsynchronousServerSocketChannel
, and more. Many other methods have been added to existing classes in the last three releases of Java, and these are discussed in the relevant chapters. I’ve also rewritten large parts of the book to reflect the ever-changing fashions in Java programming in general and network programming in particular. I hope you’ll find this fourth edition an even stronger, longer-lived, more accurate, and more enjoyable tutorial and reference to network programming in Java than the previous one.
If I've succeeded in piquing your interest, you should be able to find Java Network Programming at almost any bookstore that carries computer books including Amazon.com. It's also available on Safari. If you need to special order it, the ISBN number is 1-449-35767-9. It's $39.99, published by O'Reilly, and written by me, Elliotte Rusty Harold.