Ebook banner rotater for Web Programming and Administration

# Peter Norton's Guide to

# Java Programming

### by Peter Norton & Wiliam Stanek

## C O N T E N T S

## Introducing

## Chapter 1 Introducing Java

- What Is Java?
- The Evolution of Java
- A Brief History of the Internet and the World Wide Web
  - The Early Days of the Internet
  - The Early Days of the Web
- The Basics of Programming Languages
  - Interpreted Programming Languages
  - Compiled Programming Languages
  - Java: An Interpreted and Compiled Programming Language
- The Logical Evolution of C to C++
- The Great Leap Forward from C/C++ to Java
- Object-Oriented Programming Concepts and Java
  - Objects
  - Encapsulation and Message Passing
  - Classes
  - Libraries
  - Inheritance
  - Access Modifiers
- Programming with Java
  - The Primary Characteristics of Java
  - The Structure of the Java Language
  - The Java Specification and the API
  - The Java Virtual Machine
- Summary

## Chapter 2 Getting Started with the JDK

- The Java Developer's Environment
  - The Java API and Core Language Functions
  - Tools in the JDK
- Power Start for Solaris
  - Obtaining the Java Developer's Kit
  - Installing the Java Developer's Kit
  - Testing the Installation
- Power Start for Windows 95/NT
  - Obtaining the Java Developer's Kit
  - Installing the Java Developer's Kit
  - Testing the Installation
- Power Start for Macintosh
  - Obtaining the Java Developer's Kit
  - Installing the Java Developer's Kit
  - Testing the Installation
- Power Start for OS/2
  - Obtaining the Java Developer's Kit
  - Installing the Java Developer's Kit
  - Testing the Installation
  - Performance Tuning for OS/2
- Power Start for AIX
  - Obtaining the Java Developer's Kit
  - Installing the Java Developer's Kit
  - Testing the Installation
- Making the Transition from C/C++ to Java
  - Java Has No Compile to Machine Code
  - Java Has No External C Syntax
  - Java Has No Multiple Inheritance
  - Java Has No Namespace Problems
  - Java Has No Pointers
- Java Has No Separate Header Files
  - Java Has No Stand-alone Functions
  - Some Java Programs Have No main Function
  - Java Has No Templates
  - Java Has Exception Handling
  - Java Has Automated Garbage Collection
- Summary

## Chapter 3 The Java Browser and the World Wide Web: A Primer

- Navigating the World Wide Web
- Using URLs
  - How URLs Are Defined
  - URL Formats
- Web Surfing with Java-Enhanced Browsers
  - HotJava
  - Netscape Navigator
  - Oracle PowerBrowser
  - Internet Explorer
  - Liquid Reality
- Web Hot Spots for Java Developers
  - Sun's Web Site
  - JavaSoft
  - Gamelan
  - JARS
- Third-Party Java Tools
  - Borland C++ for Java Developers
  - Symantec Café
  - Symantec Espresso and Symantec Caffeine
  - Rogue Wave's JFactory
  - SunSoft's Java Workshop
- A Brief Tour of Live Applets on the Web
  - Dimension X Café
  - WallStreetWeb
  - Celebrity Painter
  - DigSim
  - 3D Netris
  - SGI Java-Powered Home Page
  - SportsZone
- Summary

## Chapter 4 The Java Language: A Primer

- Creating Your First Stand-alone Java Application
  - The Basic Structure of a Stand-alone Application
  - Putting It All Together
  - Creating FirstApp
  - Compiling FirstApp
  - Running FirstApp
- Your First Java Applet
  - The Basic Structure of an Applet
  - Creating the Applet
  - Compiling FirstApplet
  - Creating an HTML File for Your Applet
  - Creating an Image for Your Applet
  - Creating a Sound File for Your Applet
  - Running FirstApplet
- Troubleshooting
  - Compiler Errors
  - Interpreter Errors
  - Viewer Errors
- Summary

## Chapter 5 Java Tools and the JDK: A Primer

- Tools in the Java Developer's Kit
- Command-line Tools in the JDK
  - The Java Compiler and Associated Environment Tools
  - The Java Interpreter
  - The Java Applet Viewer
- Graphical Developer's Tools
  - Macintosh Developer's Tools
  - Java WorkShop
- Summary

## Chapter 6 Fundamentals of the Java Language

- Tokens
  - Identifiers
  - Keywords
  - Literals
  - Separators
  - Operators
  - Comments
  - Tokens Summary
- Using Data Types
  - Primitive Data Types
  - Integer Data Types
  - Reference Data Types
- Expressions
  - Using Operators in Expressions
- Declarations
  - Declaring integer Types
  - Declaring Floating-Point Types
  - Declaring character Types
  - Declaring Arrays
- Control Flow
  - Blocks and Statements
  - Conditional Expressions
  - Looping Expressions
- Summary

## Chapter 7 Building Objects

- An Introduction to Classes
  - Classes
  - Class Variables
  - Class Methods
  - Method Modifiers
  - Declaring Method Security and Accessibility
  - Overloading Methods
- Working with Objects
  - Creating and Destroying Objects
  - The Constructor Method
- Packages
  - Declaring a Package
  - Accessing Other Packages
  - Package-Naming Conventions
  - The CLASSPATH Environment Variable
  - Summary of Packages
- Inheritance
- Declaring Inheritance
  - Using Inheritance
  - Summary of Inheritance
- Interfaces
  - Declaring an Interface
  - Modifiers
  - Using an Interface
  - Summary

## Chapter 8 Tying It All Together: Threads, Exceptions, and More

- Threads
  - Uses of Threads
  - Declaring Threads
  - new and the Instantiation of Threads
  - Destroying a Thread
  - Thread Methods
  - Named Threads
  - Synchronization of Threads
  - Summary of Threads
- Exceptions
  - Rationale for Java Exceptions
  - Exception Methods
  - An Example with try, catch, and finally
  - Using try in Exception Handling
  - Using catch in Exception Handling
  - Using finally in Exception Handling
  - Using throw in Exception Handling
  - The java.lang.Exception Class
  - Summary of Exceptions
- Streams
  - Data Flow with Java Streams
  - The Importance of Streams
  - Input Streams
  - Output Streams
  - Summary of Streams
- Summary

## Chapter 9 Introducing the Java API

- The Java API Packages
- The Structure of the API Packages
  - java.lang
  - java.util
  - java.io
  - java.net
  - java.awt.image
  - java.awt.peer
  - java.applet
  - sun.tools.debug
- Using the Java API
- API Web Reference Structure
  - Package Documentation
  - Interface Documentation
  - Class Documentation
  - Exception Documentation
- Constructing Code with Documentation Information
- Summary

## Chapter 10 The java.lang and java.applet Class Libraries

- The java.applet.Applet Class
- The java.lang Package and Its Classes
  - Boolean
  - Character
  - Class
  - ClassLoader
  - Compiler
  - Number, Float, Integer, Long
  - Math
  - Object
  - Process, Runtime, System
  - SecurityManager
  - String
  - StringBuffer
  - Thread
  - ThreadGroup
  - Throwable
- java.lang Exception Classes
- An Example of an Exception from java.lang-exceptions
- Summary

## Chapter 11 The AWT Class Library

- Introduction to the AWT
- Using the Frame Class to Implement Application Windows
- Implementing Dialog Boxes with the Dialog Class
  - Using the FileDialog Class to Access the Local File System
- Organizing Components Using the Panel and Layout Classes
- Using Common GUI Controls
  - Labels and Buttons
  - Check Boxes and Radio Buttons
  - Choices and Lists
  - Text Fields and Text Areas
- Drawing with the Canvas and Graphics Classes
- Geometrical Classes
- Using Fonts
- Image-related Classes
- Using Scrollbars
- The Toolkit Class and the Native Platform Window Implementation
- Summary

## Chapter 12 The Java I/O and Utility Class Libraries

- Introduction to the java.io Package
- How Java's I/O System Works
- Java Input Streams
  - The InputStream Class
  - More on the InputStream Class and Its Subclasses
  - The ByteArrayInputStream Class
  - The FileInputStream Class
  - The SequenceInputStream Class
  - The StringBufferInputStream Class
- Java Output Streams
  - The OutputStream Class
  - Miscellaneous I/O Classes
- The java.util Package
  - The Bitset Class
  - The Date Class
  - The Dictionary Class
  - The Hashtable Class
  - The Properties Class
  - The Random Class
  - The Vector Class
  - The Stack Class
  - The StringTokenizer Class
- Summary

## Chapter 13 The Net and Debug Class Libraries

- Introduction to the Net Class Library
  - The ContentHandler Class
  - The DatagramPacket Class
  - The DatagramSocket Class
  - The InetAddress Class
  - Java Socket Handlers
  - Java URL-Related Classes
  - The URL Class
- Introducing the sun.tools.debug Library
  - The DebuggerCallback Interface
  - Methods that Deal with Remote Objects
  - The RemoteStackFrame Class
  - The RemoteStackVariable Class
  - The RemoteDebugger Class
  - The StackFrame Class
- Summary

## Chapter 14 Creating a Java Applet

- Conceptualization and Design of the QuizMaker Applet
- Defining the Applet Structure
- Building the Applet
  - Step 1: Create an HTML Document to Test the Applet
  - Step 2: Create a File Containing Included Classes
  - Step 3: Declaring the QuizMaker Class
  - Step 4: Adding Class Variables
  - Step 5: Define the Methods
  - Step 6: Compile the Applet
- The Finished Applet
  - Creating a Second Applet
  - Conceptualization and Design of the Applet
  - Defining the Applet Structure
  - Building the Applet
- The Finished Applet
- Comparing the QuizMaker Applet with the RGB2Hex Applet
- Testing and Debugging
- Summary

## Chapter 15 Greating Java-Powered Web Presentations with Applets

- Basic HTML Document Structure
  - Understanding URLs
  - Introduction to HTML Tags
  - The Header of an HTML Document
  - The Body of an HTML Document
- The Java Extensions to HTML
  - The APPLET Element
  - Optional Attributes for the APPLET Element
  - The PARAM Element
- Adding Animation to Web Documents
  - Overview of the Animator Applet
  - Using Parameters in the Animator Applet
  - Creating a Java-Based Animation with Animator
- Reducing Animation Flicker
- Publishing a Java Presentation on the Web
  - Using Live Applets
  - Putting Together the Presentation
  - Publishing the Presentation on the Web
  - Viewing the Presentation
- How Does Java Compare to Other Available Products?
  - Java Versus Perl
  - Java Versus Other Programming Languages
  - Java Versus Off-the-Shelf Software
  - Java Versus HTML
- Summary

## Chapter 16 Applet Reuse

- Adding Functionality to Existing Applets
  - Deciding Between Reusing and Rewriting Code
- When to Reuse
- When to Rewrite
- Extending an Applet
  - Reusing ScrollText
  - Reusing RGB2Hex
  - Reusing the QuizMaker Applet
  - Rewriting the QuizMaker Applet
- Testing the Extended Applet
  - Testing the ScrollText2 Applet
  - Testing the RGB2Hex2 Applet
  - Testing the Extended QuizMaker Applet
  - Testing the Rewritten QuizMaker Applet
  - Creating Tests for Your Own Applets
- Summary

## Chapter 17 Creating a Stand-alone Application

- How Stand-alone Applications Differ from Applets
  - Differences in the Code
  - Differences in Performance
  - Differences in Security
- Conceptualization and Design of the Application
- Defining the Application Structure
  - A Nongraphical Example
  - A Graphical Example
- Building the Application
  - Allowing Interactive Updates to the Application
  - Writing to the Local Hard Drive
  - Including an Applet in an Application
  - Additional Needs
- The Finished Stand-alone Application
- Summary

## Chapter 18 Using Java Applications in the Real World

- Bigger, Better, Faster Applications
- Conceptualizing a Real-World Application
  - Useful Online Resources
  - Determining Requirements
- Designing a Real-World Application
  - Overall Design and Layout
  - Design for the Main Window
  - Design for the Menu Bar
  - Design for the SlidePanel Object
  - Design for the SlideCanvas Object
  - Design for the SlideText Object
  - Design for the Controls
  - Design for the Dialog Boxes
  - File I/O
  - Relationships Among Objects
- Implementing a Real-World Application
  - Building the Main Window
  - Adding the SlidePanel Class
  - Adding the SlideCanvas Object
  - Adding the SlideText Object
  - Adding the Controls
  - Adding the Dialog Boxes
- The Complete Project
- Testing and Debugging
- Summary

## Chapter 19 Application Upgrades

- The Software Development Cycle
  - The Development Process
  - The Maintenance Process
  - Suggestions to Facilitate Modifications
- Conceptualizing Application Upgrades
  - The Build-and-Save Capability
  - Changing the State of the Check Boxes
  - Reading Multiple Files
  - Continuous Play
  - Increasing the Number of Possible Slides
  - Final Task List
- Designing Application Upgrades
  - Build-and-Save
  - Increasing the Number of Possible Slides
  - Adding Audio
  - Summing Up the Object Changes
- Implementing Application Upgrades
  - Changes to SlideCanvas
  - Changes to SlideText
  - Changes to SlidePanel
  - Changes to SlideControls
  - Changes to SlideShow
- The Final Version of SlideShow
- Testing and Debugging
  - Testing the Build-and-Save Capability
  - Testing the Check Boxes
  - Testing the Capability to Read Multiple Files
  - Testing the Continuous-Play Capability
  - Testing the Number of Possible Slides
- Summary

## Chapter 20 Designing and Implementing Advanced Applets

- Project Development and Planning
  - The Requirements Phase
  - The Specification/Analysis Phase
  - The Planning Phase
- Project Design
- The Implementation Phase
  - Containers for the Objects Used in the SpreadSheet Applet
  - Initializing the Primary Frame
  - Determining the State of the Applet
  - Running Applet Threads
  - Painting the Frame
  - Updating the Applet's Frame
  - Handling Events in the Applet
  - Updating the Current Cell's Value
  - Handling Formulas
  - Creating Cells
  - Preparing Cells for Display
  - Utility Methods
  - Parsing Formulas
  - Painting Cells
  - Building the Node Object
  - Building the Input Area
- The Complete Applet
- Putting the SpreadSheet Applet to Use
- Summary

## Chapter 21 Designing and Implementing Advanced Applications

- Project Development and Planning
  - Determining Requirements
  - Defining the Necessary Objects
  - Plotting the Project to Completion
- Project Design
- Project Implementation
  - Containers for the Objects
  - Building the Main Window
  - Adding the Menu Bar with Pull-down Menus
  - Adding the Choice Menus
  - Adding the Text Area
  - Adding File Objects
  - Setting the Wheels in Motion
  - Handling Events
  - Building the Utility Functions
  - Handling File I/O
  - Displaying the Dialog Boxes
  - Building the Dialog Boxes
  - Text-Manipulation Objects
- The Complete Project
- Summary

## Chapter 22 Integrating Native Programs and Libraries

- Why and When to Use Native Methods with Java Applications
- Using C Programs
  - Creating New C Programs for Use with Java Applications
  - Using Existing C Programs
- Using Programming Languages Other Than C
  - C++ Programs
  - Programs in Other Languages
- Summary

## Chapter 23 Advanced Debugging and Troubleshooting

- Starting the Java Debugger
  - Starting the Debugger Directly
  - Attaching the Debugger to a Current Interpreter Session
  - Attaching the Debugger to an Applet Viewer Session
- Troubleshooting the Code with the Debugger
  - Examining Threads
  - Examining Methods and Classes
  - Examining Instance Variables
- Identifying Trouble with the Code
- Summary

## Chapter 24 The Java Virtual Machine

- Introducing the Virtual Machine
- The Basic Parts of the Java Virtual Machine
  - Registers
  - The Stack
  - The Execution Environment
  - The Garbage-Collected Heap
  - The Constant Pool
  - The Method Area
  - The Bytecode Instruction Set
- Examining Bytecode
- A Walk-through of the Instruction Set
  - Pushing Constants onto the Stack
  - Loading Local Variables onto the Stack
  - Storing Stack Values into Local Variables
  - Handling Arrays
  - Handling the Stack
  - Performing Arithmetic
  - Logical Instructions
  - Handling Conversions
  - Control Transfer Instructions
  - Returning from Methods
  - Table Jumping
  - Manipulating Object Fields
  - Invoking Methods
  - Exception Handling
  - Miscellaneous Object Operations
  - Monitors
- Breaking Down the Class File Format
- Signatures
- Summary

## Appendix A Java API Table Reference

## Appendix B Java Terminology

## Credits

####
To the dreamers of the world who dream the perfect dreams and then create wonderful things like Java.

Copyright © 1996 by Peter Norton

#### 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-088-6

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

#### Trademarks

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. Peter Norton's stylized signature, and Peter Norton's crossed-arms pose are registered trademarks of Peter Norton. 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 Marketing Manager | Kristina Perry, Rachel Wolfe

Acquisitions Editor | Christopher Denny | Development Editor | Anthony Amico, L. Angelique Brittingham
Software Development Specialist | Steve Straiger | Production Editor | Kimberly K. Hannel
Copy Editor | Marilyn Stone | Indexer | Tom Griffin
Technical Reviewers | Karen Clere, Christopher Stone | Editorial Coordinator | Bill Whitmer |
Technical Edit Coordinator | Lynette Quinn | Resource Coordinator | Deborah Frisby
Formatter | Frank Sinclair | Editorial Assistants | Carol Ackerman, Andi Richter, Rhonda Tinch-Mize,
Cover Designer | Tim Amrhein | Book Designer | Alyssa Yesh
Copy Writer | Peter Fuller | Production Team Supervisor | Brad Chinn
Production | Mary Ann Abramson, Georgiana Briggs, Susan Knose, Ayanna Lacey

## Acknowledgments

Creating the perfect book on Java programming required a great deal of effort-long hours, days without sleep, grueling research, and much more. I want to personally thank everyone who poured their heart into this book.

Special thanks to my wife and family, who continue to put up with the tappety-tap of my keyboard at all hours of the day and night. Without your support, this book wouldn't have been possible.

## About the Author

William Robert Stanek (`director@tvp.com`) is the publisher and founder of The Virtual Press (http://tvp.com/ and mirror site http://www.tvpress.com/), a non-traditional press established in March 1994. As a publisher and writer with over 10 years of experience on networks, he brings a solid voice of experience on the Internet and electronic publishing to his many projects. He was first introduced to Internet e-mail in 1988 when he worked for the government, and has been involved in the commercial Internet community since 1991.

His years of practical experience are backed by a solid education, including a Master of Science in Information Systems and a Bachelor of Science in Computer Science. While his press publishes electronic books under four imprints, the core business is shifting, and the time that isn't spent writing such runaway hits as Sams.net's Web Publishing Unleashed is spent consulting with corporate clients and developing hot new Web sites.

William served in the Persian Gulf War as a combat crew member on an Electronic Warfare aircraft. During the war, he flew on numerous combat missions into Iraq and was awarded nine medals for his wartime service including one of our nation's highest flying honors, the Air Force Distinguished Flying Cross. He has written many books, articles, and essays. His book-length projects include nine fiction titles and six nonfiction titles. Watch for the upcoming release of his FrontPage Unleashed from Sams.net in August 1996. When he's not writing or working, he spends time with his family, his favorite time of the day being when he reads to his youngest child.

## 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, in what areas you'd like to see us publish, 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

## Introduction

Peter Norton's Guide to Java Programming is the definitive guide to the Java programming language. It is designed to meet the needs of today's Web publishers and programmers by helping you set the pace for the future of Internet and object-oriented programming. Not only does this book provide the broadest and most extensive coverage of essential issues, it is the only book on the market of its kind.

Java represents the future of object-oriented programming, and Peter Norton's Guide to Java Programming is the key to this future. We have taken great care to provide invaluable tips and pour our expertise into every page. As you read this book, you will learn about everything the Java programming language has to offer.

For Internet developers, programmers, and Web publishers, now is the time to get in on the inside track to Java. Throughout much of 1995, Java was in Alpha and Beta testing. During this time, Java development was limited to the Solaris and Windows NT environments. But all this quickly changed as word about Java spread like wildfire. In January 1996, Sun Microsystems officially released Java 1.0, and you can now obtain free developer's kits for every major operating system including Solaris, AIX, Windows 95/NT, OS/2, and Macintosh.

For non-programmers, using a programming language such as Java may seem impossible, but nothing could be further from the truth. The simple fact is that if you can create an HTML, a SGML, or a VRML document, you should be able to create Java-powered documents and applications as well. You will find that Java is easy to learn and use because it eliminates or automates many of the problem areas of earlier programming languages.

The power of Java is that even the most basic Java programs can feature multimedia. This is primarily because the fundamentals of the Java programming language are easy to learn and use. Through a plain-English approach, I guide you from the fundamentals to advanced programming and beyond. Here are the major topics covered in this book:

- Getting started
- The fundamentals of the Java programming language
- Using the Java Developer's Kit
- A complete walk-through of the Java Application Programming Interface
- Developing Java applets for the Web
- Using applets in Web publications
- Reusing applets
- Developing stand-alone applications
- Using Java applications in the real world
- Application upgrades
- Developing advanced applets
- Developing advanced applications
- Advanced debugging and troubleshooting
- An inside look at the Java Virtual Machine
- Online resources for Java

### Who Should Read This Book?

Peter Norton's Guide to Java Programming is for today's Web publishers and programmers. Although this book is intended for those with a casual to accomplished knowledge of programming or Web publishing, the plain-English approach makes this book perfect for just about anyone. I truly hope you find this book to be invaluable as you plot your course to success in Java programming.

## How This Book Is Organized

This book is designed to be the most comprehensive resource on the Java programming language available anywhere. Chapter by chapter, you will learn everything you need to know to develop and design powerful programs using Java.

Part I, "Next Stop-Java," covers everything you need to know to get started. After introducing the Java programming language and the basic principles of object-oriented programming, Chapter 1 explores the evolution of programming languages and how Java came to be. Chapter 2 details everything the programmer or Web publisher needs to get started with creating Java programs, including installing the Java Developer's Kit. The chapter also provides insight into how C/C++ programmers can best make the transition to Java.

The primers in Part II, "Power Primers," are designed to give you a jump-start on Java development. In addition to being a primer on the World Wide Web, Chapter 3 demonstrates the power of Java through a discussion of the multimedia uses of Java on the Web. Chapter 4 provides a primer on the Java programming language. In this chapter, you create your first Java applet and a Java application. Chapter 5 discusses the essential tools for creating and developing Java programs and how to use them. Featured tools include the developer's tools in the Java Developer's Kit and Java WorkShop, a hot new graphical development environment.

Part III, "Anatomy of the Java Language," examines the inner workings of the Java programming language. Chapter 6 explores the fundamentals of the language including tokens, types, expressions, declarations, and control flow statements. In Chapter 7, everything discussed so far starts to come together as you learn that Java objects are built from classes that contain the fundamentals, a group of classes forms a package, and abstract classes called interfaces patch the structure together. Chapter 8 explores the key concepts of multithreading, error handling, and streaming. These concepts are essential to complete the final pieces of Java programming theories.

The Java Application Programming Interface contains a wealth of ready-to-use code that can save you development time and money. Part IV, "The Java Application Programming Interface," examines everything the API has to offer. In Chapter 9, you will find a list of all available API packages and their relation to one another. Chapter 10 examines the Applet and Language class libraries and their uses in Java programs. Chapter 11 examines the Abstract Windowing Toolkit library and its uses in Java programs. Chapter 12 examines the I/O and Utility libraries and their uses in Java programs. Chapter 13 examines the Net and Debug libraries and their uses in Java programs.

Part V, "Developing Java Applets for the Web," details everything you need to know to develop Java programs for use on the Web. Through example applets, Chapter 14 demonstrates the structure of basic and intermediate-level applets and provides steps for building your own applets. After creating and testing an applet, the next important step is incorporating the applet into an HTML document for use on the World Wide Web. Chapter 15 begins with a brief overview of HTML document structure and then explores HTML elements associated with Java applets. Finally, the chapter shows how the applet can be used in Web publications. An essential concept in object-oriented programming is reusing existing code, which saves development time and money. Chapter 16 discusses when and how to reuse code and provides real-world examples.

Part VI, "Developing Stand-alone Applications," details everything you need to know to develop stand-alone applications. Chapter 17 begins by examining how Java applications differ from applets and then demonstrates the structure of basic and intermediate-level applications. Because useful stand-alone applications are more difficult to create than applets, Chapter 18 provides insight into and examples of the features needed in applications. The chapter goes on to discuss how to increase the functionality of applications. In the real world, software applications have a development life cycle. Chapter 19 explains this life cycle in more detail than previous chapters and shows how to successfully implement application upgrades.

In Part VII, "Advanced Issues," you explore advanced design and development issues. Chapter 20 provides a hands-on example and complete walk-through of an advanced applet. You can use this chapter as a stepping stone for creating your own advanced applets. Chapter 21 provides a hands-on example and complete walk-through of an advanced application. You can use this chapter as a stepping stone for creating your own advanced applications. In Chapter 22, you learn how to use native programs and libraries with Java. These native programs can be in any other programming language including C, C++, and Smalltalk. Debugging and troubleshooting is another important part of programming. Chapter 23 explores advanced debugging issues and provides hands-on examples of using the Java debugger. The final chapter provides a detailed look at the Java runtime system and the Virtual Machine. Understanding the abstract specification of the Java Virtual Machine provides wonderful insight into how Java truly works.

The final section of the book puts key reference resources into your hands. Appendix A, "Java API Table Reference," is an invaluable at-a-glance resource for the Java API. Appendix B, "Java Terminology," is a glossary of terms you will use when working with Java.

### Conventions Used in This Book

I have used the following conventions in this book.

### Type Conventions

`monospace` | This computer font is used to represent code, whether onscreen or typed by you, and for filenames, directory names, and other nonstandard words.
`italic monospace` | I use italic computer font when the text is a placeholder or a variable rather than absolute code.
`italic` | Italic type is used to call your attention to new terms.

## Icons

Note
Notes tell you about interesting facts that aren't really necessary to your understanding of Java; they're just for your information.

Tip
Tips contain tidbits of information that you might not learn elsewhere, or sometimes just tell you about a different way of doing something.

Warning
Warnings mean watch out-you can get into some trouble! Make sure you understand a warning before you follow any instructions that come after it.

Peter's Principle
I'll use the Peter's Principle icon to tell you about a rule that you might adopt as a standard operating procedure. It's like a tip that you can implement to improve general situations, and you can always use the principle as a rule to live by.

Looking Ahead
I include these boxes to give you a peek at what's coming up later and tell you how what you're currently reading will help you then.

The capability icon is intended to alert you to a situation or condition that you should track. It means that situation is dynamic and that better facilities are becoming available all the time.

Watch for the development issue icon to tell you how to implement or expand some function. In some ways it might be like the troubleshooting icon in that it tells you about a possible problem, but it will always offer some solution to the problem.

Each time you see the performance icon I'll be telling you about a technique you can use to make your product more efficient. I may offer some alternatives so that you can choose which method is best for you.

When you see this icon it means that there is a possibility for something to go wrong. The text shows you how to identify the problem and suggests a method for solving it.