J A V A

     DEVELOPER'S   REFEREncE


by Mike Cohn
    Bryan Morgan
    Michael Morrison
    Michael T. Nygard
    Dan Joshi
    Tom Trinko


C  O  N  T  E  N  T  S




PART I  The Java Development System

Chapter 1  Introduction to Java

Chapter 2  Installing Java

Chapter 3  The Java Language

Chapter 4  Java for C++ Programmers

Chapter 5  Java for Delphi Programmers

Chapter 6  Java for Visual Baisc Programmers

Chapter 7  Developing Java Applets

Chapter 8  Developing Java Applications

Chapter 9  javac : The Java Compiler

Chapter 10  java : The Java Interpreter

Chapter 11  Using the Applet Viewer

Chapter 12  HTML for Java Programmers

Chapter 13  HotJava and Other Java-Enabled Browsers

Chapter 14  Using javah

Chapter 15  jdb: The Java Debugger

Chapter 16  Using JavaDoc to Document Your Program

PART II  Using the Java Packages

Chapter 17  Programming the User Interface

Chapter 18  Writing Secure Programs

Chapter 19  Extending Your Programs with Native Methods

Chapter 20  Working with Threads

Chapter 21  Event Handling

Chapter 22  Exception Handling

Chapter 23  Using Observers

Chapter 24  Using the Provided Data Structures

Chapter 25  Working with Databases

Chapter 26  Network-Aware Programming

PART III  Package, Class, and Interface Reference

Chapter 27  Package java.applet

Chapter 28  Package java.awt

Chapter 29  Packages java.awt image

Chapter 30  Package java.awt.peer

Chapter 31  Package java.io

Chapter 32  Package java.lang

Chapter 33  Package java.net

Chapter 34  Package java.util

Chapter 35  Package sun.tools.debug


Credits



Copyright © 1996 by Sams.net Publishing

FIRST EDITION

All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290.

International Standard Book Number: 1-57521-129-7


HTML conversion by :
    M/s. LeafWriters (India) Pvt. Ltd.
    Website : http://leaf.stpn.soft.net
    e-mail : leafwriters@leaf.stpn.soft.net

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.net Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Java is a trademark of Sun Microsystems, Inc.


President, Sams Publishing Richard K. Swadley
Publishing Team Leader Greg Wiegand
Managing Editor Cindy Morrow
Director of Marketing John Pierce
Assistant Markerting Managers Kristina Perry, Rachel Wolfe


Acquisitions Editor Christopher Denny Development Editor Anthony Amico
Software Development Specialist Brad Myers Senior EditorKristi Hart
Production Editor Bart Reed
Copy Editors Margaret Berson, Fran Blauw, Lisa Lord, Marla Reece, Kris Simmons
IndexerTom Dinse Technical Reviewer Karen Clere, Vincent Mayfield
Editorial Coordinator Bill Whitmer Technical Edit Coordinator Lynette Quinn
Resource Coordinator Deborah Frisby
Editorial Assistants Carol Ackerman, Andi Richter, Rhonda Tinch-Mize
Cover Designer Jay CorpusBook Designer Alyssa Yesh
Copy Writer Peter FullerProduction Team Supervisor Brad Chinn
ProductionCharlotte Clapp, Jeanne Clark, Merry Dankanich, Mike Dietsch, Mike Henry, Tim Osborn, Shawn Ring, M. Anne Sipahimalani, Becky Stutzman





Acknowledgments

A book of this size is clearly a team effort. We would like to thank Chris Denny, our acquisitions editor, for getting the ball rolling. Thanks also to Tony Amico, our development editor, who, once the ball was rolling, made sure we all rolled in the same direction. Thanks also to Vincent Mayfield and Karen Clere, our technical editors, who had the difficult job of making sure that what we wrote remained accurate as the Java language continued to evolve.

Much of what we've written would be less useful without the work of Alyssa Yesh, who designed the icons used throughout the book. Similarly, our thanks go to Brad Myers, who converted the reference section into HTML files for inclusion on the CD. Fittingly, these two have helped make this book more than the sum of its words.

Finally, special thanks to Bart Reed, our production editor, who pulled everything together and who taught us why "production editor" starts with "prod."

Special Thanks from Mike Cohn:

I would like to thank Jim Kearns and Jim Steeb of Access Health for their encouragement and for providing a cutting edge environment that needs products like Java. Thanks also to the two teachers who taught me how to write-John Dale, formerly of Rancho Alamitos High School, and my mother, Carlene. Special thanks to my daughter, Savannah, for just being who you are. Finally, nothing would be possible without the love and encouragement I receive from my wife, Laura. I love you. Thanks for being my kid's mom.

Special Thanks from Michael Morrison:

I'd like to thank my faithful and now legal accomplice, Mahsheed, for all your love and support.

Special Thanks from Tom Trinko:

Special thanks to the good Lord for all His blessings, especially my wife Colleen and the kids-Kate, Peter, Ted, Mary, and Therese.


About the Authors

Mike Cohn is the Director of Information Technology at Access Health, Inc., the leading provider of personal health management. Before that he was with Andersen Consulting and the Adler Consulting Group in New York. He holds a Masters degree in Computer Science from the University of Idaho and has been programming for 16 years. Mike lives in Cameron Park, California with his wife, Laura, and their daughter, Savannah.

Bryan Morgan is a software engineer with TASC, Inc. in Fort Walton Beach, Florida. He holds a B.S. in Electrical Engineering from Clemson University and is currently using Java to build Web applications as well as to perform Web-based distributed interactive simulations. Bryan and his wife, Becky, are expecting their first child in November 1996. Bryan is the co-author of Teach Yourself SQL in 14 Days and Teach Yourself ODBC in 21 Days for Sams Publishing.

Michael Morrison is the author of Teach Yourself Internet Game Programming with Java in 21 Days, co-author of Windows 95 Game Developer's Guide, Using the Game SDK, and is a contributing author of Tricks of the Java Programming Gurus and Java Unleashed.

Michael Nygard received his B.S. from the California Institute of Technology in 1994. He is currently employed by TASC, Inc. in Fort Walton Beach, Florida, where he is a Member of Technical Staff in the Simulation Technologies Department. Michael investigates leading-edge technologies and is currently focusing on Java, Delphi, and Windows NT.

Dan Joshi is a professional developer working for several Fortune 100 companies. He currently owns his own Internet-based consulting company, The Joshi Group. Dan is also a co-author of Teach Yourself Java in Cafe in 21 Days.

Tom Trinko, Mad Scientist. Born human. Unclear if he's stayed same. Worked on just about every type of computer since 1972. Expert on the world's only user-friendly computers, the Macintosh and Newton, with a couple of books on Mac scripting on his resume. When coherent, he can be reached at trinkos@aol.com, 72147,3723 on CompuServe, or via his Web page at http://members.aol.com/trinkos/basepage.html, which features some nice (in his unbiased opinion) Java stuff, including a cellular automata engine.

Tell Us What You Think!

As a reader, you are the most important critic and commentator of our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make strong books that meet your needs and give you the computer guidance you require.

Do you have access to CompuServe or the World Wide Web? Then check out our CompuServe forum by typing GO SAMS at any prompt. If you prefer the World Wide Web, check out our site at http://www.mcp.com.

Note
If you have a technical question about this book, call the technical support line at (800) 571-5840, ext. 3668.

As the team leader of the group that created this book, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this book-as well as what we can do to make our books stronger. Here's the information:

Fax:(317) 581-4669
E-mail:programming_mgr@sams.mcp.com
Mail:Greg Wiegand
Comments Department
Sams Publishing
201 W. 103rd Street
Indianapolis, IN 46290

Conventions Used in This Book

This book uses the following conventions: