EARTH WEEK
Now through April 22, save up to 70% on digital learning resources. Learn more.
Register your product to gain access to bonus material or receive a coupon.
The Java(tm) Tutorial Continued provides accurate, up-to-date coverage of features added to the original core Java platform. Written by the experts, The Java Tutorial Continued employs a hands-on, self-paced, example-driven approach. This book concentrates on JDK 1.2 APIs but also contains the information you need to use the JDK 1.1 versions of the APIs.
The tutorial books, including this book and The Java Tutorial, are the definitive programmers' guides to the core JDK. This book covers a broad spectrum of JDK features, including:
The accompanying CD-ROM contains all the material from both The Java Tutorial and The Java Tutorial Continued in HTML, including the source code for all of the examples. The CD-ROM also has much more, including the JDK and everything you need to start programming with JDK 1.2.
You will come away from this tutorial with an excellent conceptual understanding of the JDK, along with the practical know-how to put the Java platform to work for you.
Preface.
Overview of JDK Features.
Lesson 1 A Day in the Life.
Lesson 2 All Things New with JDK 1.2.
Lesson 3 Features Roadmap.
Lesson 4 Introduction.
Lesson 5 Interfaces.
Lesson 6 Implementations.
Lesson 7 Algorithms.
Lesson 8 Custom Implementations.
Lesson 9 Interoperability.
Lesson 10 Overview of the Java 2D API.
Lesson 11 Displaying Graphics with Graphics2D.
Lesson 12 Manipulating and Displaying Images.
Lesson 13 Printing.
Lesson 14 Playing Sounds.
Lesson 15 Java Sound Engine Integration.
Lesson 16 Common Problems (and Their Solutions).
Lesson 17 JavaBeans Concepts and Development Kit.
Lesson 18 Using the BeanBox.
Lesson 19 Writing a SimpleBean.
Lesson 20 Properties.
Lesson 21 Manipulating Events in the BeanBox.
Lesson 22 The BeanInfo Interface.
Lesson 23 Bean Customization.
Lesson 24 Bean Persistence.
Lesson 25 JDBC Basics.
Lesson 26 New Features in the JDBC 2.0 API.
Lesson 27 Introducing Java IDL.
Lesson 28 The Hello Client-Server Example.
Lesson 29 Java IDL Summary.
Lesson 30 An Overview of RMI Applications.
Lesson 31 Writing an RMI Server.
Lesson 32 Creating A Client Program.
Lesson 33 Compiling and Running the Example.
Lesson 34 Overview of Servlets.
Lesson 35 Interacting with Clients.
Lesson 36 The Life Cycle of a Servlet.
Lesson 37 Saving Client State.
Lesson 38 The servletrunner Utility.
Lesson 39 Running Servlets.
Lesson 40 Security Features Overview.
Lesson 41 Quick Tour of Controlling Applets.
Lesson 42 Quick Tour of Controlling Applications.
Lesson 43 Secure Code and File Exchanges.
Lesson 44 Tools to Sign Code and Grant Permissions.
Lesson 45 Tools for Exchanging Files.
Lesson 46 Generating and Verifying Signatures.
Lesson 47 Implementing Your Own Permission.
Lesson 48 Using JAR Files: The Basics.
Lesson 49 Signing and Verifying JAR Files.
Lesson 50 Using JAR-Related APIs Introduced in 1.2.
Lesson 51 Creating and Using Extensions.
Lesson 52 Setting Extension Security Privileges.
Lesson 53 Overview of the JNI.
Lesson 54 Writing a Java Program with Native Methods.
Lesson 55 Integrating Java and Native Programs.
Lesson 56 Interacting with Java from the Native Side.
Lesson 57 Invoking the Java Virtual Machine.
Lesson 58 Summary of the JNI.
Lesson 59 Examining Classes.
Lesson 60 Manipulating Objects.
Lesson 61 Working with Arrays.
Lesson 62 Summary of Classes.
Lesson 63 Understanding Garbage Collection.
Lesson 64 All About Reference Objects.
As the title implies, this volume of The Java Tutorial starts where the first ended. The first book covers API present in the Java platform's first release.
This book covers API subsequently added to the Java platform.
This book is a collection of tutorials written by Java team members. Each author who contributed to this book is an authority in his or her area of the Java platform. Some authors are even the creators of the API they describe.
The content of this book is available online, along with the content of the first volume here:
http://java.sun.com/docs/books/tutorial/index.htmlFrom the online tutorial to the first volume, and from the first volume to this one, our intent has always been to create a fun, easy-to-read, task-oriented programmer's guide with lots of practical examples to help people learn to program using the Java platform.
The hyperlinked origins of this book will be evident as you read it. For instance, underlined phrases throughout this book mimic online links. A link to material within this book is followed by the appropriate page number. A link to material outisde this book, such as to the JDK API documentation, is accompanied by a footnote that contains a URL. Other evidence of this book's online origin can be found on the first page of each trail/lesson, which provides the URL where the trail/lesson can be found in the online tutorial.
You might be wondering why we use the terms "trails" and "lessons." We know that people don't learn linearly. People learn by posing a problem, solving it, uncovering other problems, solving them, and learning information as the need arises. Our original vision for the online tutorial was to encourage and enable this type of thinking and learning. We envisioned a mountain of ski trails, where at any junction, a reader could choose the most interesting or appropriate path at that time. But we also needed some sort of structure and organization, so we created a two-tier hierarchy; trails at the top level and lessons within them. We also use a high level of linking to help you pick and choose where you go and when.
This book documents the Java Development Kit TM (JDK) 1.2 release of the Java platform. To compile and run the examples in this book you need a development environment that is compatible with JDK 1.2. You can use a commercially available development environment or the JDK itself. We've included JDK 1.2 on the CD-ROM that accompanies this book. Or you might want to visit the Java Web side to download the latest version of the JDK:
http://java.sun.com/products/jdk/1.2/If you are using the JDK provided by Sun Microsystems, you will need one of the following systems:
If you are developing applets, you will need a browser that supports the 1.2 API, or install the Java Plug-in. The Java Plug-in ensures that your browser uses the latest Java Runtime Environment compatible with JDK 1.2. The Java Plug-in is included on the CD-ROM that accompanies this book and is also available online here:
http://java.sun.com/products/plugin/For testing applets, you could also use a special limited browser called the Applet Viewer that ships with the JDK.
Finally, you need an editor that can save files in ASCII format with a .java extension. Also, the editor must allow you to specify both uppercase and lowercase letters in the filename.
Find out more about the authors who contributed to this book.
Deborah Adair, the technical writer for the Java Media group at Sun Microsystems, specializes in designing and writing documentation for software developers and other highly technical readers. She has a degree in Scientific and Technical Communication from the University of Washington and has been writing for the computer industry for the past nine years.
Cynthia Bloch writes technical documentation at Sun Microsystems' Java Software division. She has a Master's in Information Science from the University of Pittsburgh. Since graduate school she has worked as a Senior Software Engineer at Carnegie Group Incorporated in Pittsburgh, Pennsylvania, and as a Senior Technical Trainer at Transarc Corporation in Pittsburgh, Pennsylvania.
Joshua Bloch is a Senior Staff Engineer at Sun Microsystems' Java Software division, where he works as an architect in the Java Language Group. His major contributions include the Collections Framework and java.math
.
In a former life, Josh was a Senior Systems Designer at Transarc Corporation in Pittsburgh, Pennsylvania, where he designed and implemented many parts of the Encina distributed transaction processing system. In the deep dark past, he held summer positions at the usual corporate research labs (Bell Labs and IBM Research).
Josh holds a Ph.D. in computer science from Carnegie-Mellon University, where he wrote a long, boring dissertation on replication, and designed and implemented the language layer of the Camelot distributed transaction processing system. He holds a B.S. in computer science from Columbia.
Mary Dageforde writes software documentation for various Silicon Valley computer companies, including Sun Microsystems. She has a Master's in Computer Science from Stanford University. She spent ten years working primarily on the design and implementation of the English-like customer programming language for the pioneering Xerox Star GUI environment and its successors. For the past eight years she has concentrated on documenting APIs, languages, tools, and systems.
Maydene Fisher has extensive experience as a technical writer specializing in the documentation of object-oriented programming languages. Fisher began her technical writing career on Wall Street, where she documented complex computer models, written in C++, for simulating fixed income derivatives. Before joining the JDBC team at Sun's Java Software division, she wrote documentation for ScriptX, an object-oriented multimedia scripting language, at Kaleida Labs and at Apple Computer.
Dale Green is a staff writer with Sun Microsystems, where he documents APIs for the Java programming language. In previous lives he programmed business applications, designed databases, taught technical classes, and documented RDBMS products. In his current incarnation he writes about internationalization and reflection APIs for the Java Tutorial.
Jim Inscore has worked as a technical writer for the past 18 years, documenting API for NeXT, Kaleida, Macromedia, Oracle, Objectivity, and a number of other companies. He is currently publications manager for enterprise, server, and multimedia technologies in Java Software.
In his spare time, Jim hangs out with his family and works on remodeling his house.
Monica Pawlan is a staff writer for the Java Developer Connection (JDC), and contributing author for the Java Tutorial. She has a background in 2D and 3D graphics, security, and database products, and loves to study and write about emerging technologies. When not writing, she spends her spare time gardening, studying classical piano, and dreaming of far away places--some of which she occasionally visits.
Andy Quinn is a Sun Microsystems technical writer who specializes in writing for software developers.
Before moving to Silicon Valley, Alan Sommerer was a physicist on the staff of the International Institute of Theoretical and Applied Physics at Iowa State University. After moving to California, he joined Warthman Associates in Palo Alto, where he did technical writing and applet programming for a variety of high- tech firms. Alan now writes documentation about the Java Development Kit for Sun Microsystems.
Beth Stearns is the president of Computer Ease Publishing, a computer consulting firm she founded in 1982. Her client list includes Sun Microsystems Inc., Silicon Graphics Inc., Oracle Corporation, and Xerox Corporation, among others. Her Understanding EDT, a guide to Digital Equipment Corporation's text editor, has sold throughout the world. She received her B.S. degree from Cornell University and a Master's degree from Adelphi University.
Beth is an avid cyclist, hiker, gourmet cook, and Francophile, and she plans to retire with her two cats and husband to the southwest of France.
Jim Waldo is a Senior Staff Engineer with Sun Microsystems, where he leads a team developing a distributed programming infrastructure for Java. Before joining Sun's Java Software division, he was a Principle Investigator in Sun Labs, doing research into the areas of object-oriented programming and systems, distributed computing, and user environments. Jim is also on the faculty of Harvard University, where he teaches distributed computing in the department of computer science. He received his Ph.D. in philosophy from the University of Massachusetts (Amherst). He also holds M.A. degrees in both linguistics and philosophy.
Ann Wollrath is a senior staff engineer with Sun Microsystems where she is the architect and project lead of the Java Remote Method Invocation system. Previously during her tenure at Sun Microsystems Laboratories and at the MITRE Corporation, she researched reliable, largenscale distributed systems and parallel computation. Wollrath received an M.S. in computer science from the University of Massachusetts, Lowell, and a B.S. in computer science from Merrimack College.
The editors would like to thank the authors who contributed to this volume. Their work on this book was in addition to their normal, crazy workload. We appreciate their hard work and enthusiasm for this project.
Our reviewers include a patient group of readers at Sun Microsystems, and our Internet readers who send us email to cheerfully point out our errors and help us revise our awkward sentences. In particular, we'd like to thank Tim Lindholm and Lisa Friendly for helping to review the trails in this book.
Our team managers, Lisa Friendly, Rick Levenson, and Stans Kleijnen, create a supportive work environment that helps us get our job done. Mike Hendrickson, our editorial advisor at Addison-Wesley, is a constant motivator. Sarah Weaver was the wonderful production manager on the book who kept us on schedule.
Evelyn Pyle was our eagle-eyed copy editor. The whole team at Addison-Wesley have been a pleasure to work with and continually strive for excellence on this and the other books in the series.