Cover image for Java Cookbook

Book description

The Java Cookbook is a comprehensive collection of problems, solutions, and practical examples for anyone programming in Java. Developers will find hundreds of tried-and-true Java "recipes" covering all of the major APIs as well as some APIs that aren't as well documented in other Java books. The Java Cookbook, like the bestselling Perl Cookbook, covers a lot of ground, and offers Java developers short, focused pieces of code that can be easily incorporated into other programs. The idea is to focus on things that are useful, tricky, or both. The book includes code segments covering many specialized APIs--like media and servlets--and should serve as a great "jumping-off place" for Java developers who want to get started in areas outside of their specialization. The book provides quick solutions to particular problems that can be incorporated into other programs, but that aren't usually programs in and of themselves.

Table of Contents

  1. Java Cookbook
    1. Preface
      1. Who This Book Is For
      2. What’s in This Book?
      3. Platform Notes
      4. Other Books
        1. Other Java Books
        2. General Programming Books
        3. Design Books
      5. Conventions Used in This Book
        1. Programming Conventions
        2. Typesetting Conventions
      6. Comments and Questions
      7. Getting the Source Code
      8. Acknowledgments
    2. 1. Getting Started: Compiling, Running, and Debugging
      1. Introduction
      2. Compiling and Running Java: JDK
        1. Problem
        2. Solution
          1. JDK
          2. Command-line alternatives
          3. MacOS
      3. Editing and Compiling with a Color-Highlighting Editor
        1. Problem
        2. Solution
        3. Discussion
      4. Compiling, Running, and Testing with an IDE
        1. Problem
        2. Solution
        3. Discussion
      5. Using Classes from This Book
        1. Problem
        2. Solution
        3. Discussion
      6. Automating Compilation with jr
        1. Problem
        2. Solution
        3. Discussion
      7. Automating Compilation with make
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Automating Compilation with Ant
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. Running Applets
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Dealing with Deprecation Warnings
        1. Problem
        2. Solution
        3. Discussion
      11. Conditional Debugging without #ifdef
        1. Problem
        2. Solution
        3. Discussion
      12. Debugging Printouts
        1. Problem
        2. Solution
        3. Discussion
      13. Using a Debugger
        1. Problem
        2. Solution
        3. Discussion
      14. Unit Testing: Avoid the Need for Debuggers
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      15. Decompiling Java Class Files
        1. Problem
        2. Solution
        3. Discussion
      16. Preventing Others from Decompiling Your Java Files
        1. Problem
        2. Solution
        3. Discussion
      17. Getting Readable Tracebacks
        1. Problem
        2. Solution
        3. Discussion
      18. Finding More Java Source Code
        1. Problem
        2. Solution
        3. Discussion
      19. Program: Debug
    3. 2. Interacting with the Environment
      1. Introduction
      2. Getting Environment Variables
        1. Problem
        2. Solution
        3. Discussion
      3. System Properties
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Writing JDK Release-Dependent Code
        1. Problem
        2. Solution
        3. Discussion
      5. Writing Operating System-Dependent Code
        1. Problem
        2. Solution
        3. Discussion
      6. Using CLASSPATH Effectively
        1. Problem
        2. Solution
        3. Discussion
      7. Using Extensions or Other Packaged APIs
        1. Problem
        2. Solution
        3. Discussion
      8. Parsing Command-Line Arguments
        1. Problem
        2. Solution
        3. Discussion
    4. 3. Strings and Things
      1. Introduction
      2. Taking Strings Apart with Substrings
        1. Problem
        2. Solution
        3. Discussion
      3. Taking Strings Apart with StringTokenizer
        1. Problem
        2. Solution
      4. Putting Strings Together with + and StringBuffer
        1. Problem
        2. Solution
      5. Processing a String One Character at a Time
        1. Problem
        2. Solution
        3. Discussion
      6. Aligning Strings
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Converting Between Unicode Characters and Strings
        1. Problem
        2. Solution
        3. See Also
      8. Reversing a String by Word or Character
        1. Problem
        2. Solution
        3. Discussion
      9. Expanding and Compressing Tabs
        1. Problem
        2. Solution
        3. Discussion
      10. Controlling Case
        1. Problem
        2. Solution
      11. Indenting Text Documents
        1. Problem
        2. Solution
      12. Entering Non-Printable Characters
        1. Problem
        2. Solution
        3. Discussion
      13. Trimming Blanks from the End of a String
        1. Problem
        2. Solution
        3. Discussion
      14. Parsing Comma-Separated Data
        1. Problem
        2. Solution
        3. Discussion
      15. Program: A Simple Text Formatter
      16. Program: Soundex Name Comparisons
    5. 4. Pattern Matching with Regular Expressions
      1. Introduction
        1. See Also
      2. Regular Expression Syntax
        1. Problem
        2. Solution
      3. How REs Work in Practice
        1. Problem
        2. Solution
      4. Using Regular Expressions in Java
        1. Problem
        2. Solution
        3. Discussion
      5. Testing REs Interactively
        1. Problem
        2. Solution
        3. Discussion
      6. Finding the Matching Text
        1. Problem
        2. Solution
      7. Replacing the Matching Text
      8. Printing All Occurrences of a Pattern
        1. Problem
        2. Solution
      9. Printing Lines Containing a Pattern
        1. Problem
        2. Solution
      10. Controlling Case in match( ) and subst( )
        1. Problem
        2. Solution
      11. Precompiling the RE
        1. Problem
        2. Solution
        3. Discussion
      12. Matching Newlines in Text
        1. Problem
        2. Solution
        3. Discussion
      13. Program: Data Mining
      14. Program: Full Grep
    6. 5. Numbers
      1. Introduction
        1. See Also
      2. Checking Whether a String Is a Valid Number
        1. Problem
        2. Solution
        3. Discussion
      3. Storing a Larger Number in a Smaller
        1. Problem
        2. Solution
        3. Discussion
      4. Taking a Fraction of an Integer Without Using Floating Point
        1. Problem
        2. Solution
        3. Discussion
      5. Ensuring the Accuracy of Floating-Point Numbers
        1. Problem
        2. Solution
      6. Comparing Floating-Point Numbers
        1. Problem
        2. Solution
      7. Rounding Floating-Point Numbers
        1. Problem
        2. Solution
      8. Formatting Numbers
        1. Problem
        2. Solution
        3. See Also
      9. Converting Between Binary, Octal, Decimal, and Hexadecimal
        1. Problem
        2. Solution
        3. Discussion
      10. Operating on a Series of Integers
        1. Problem
        2. Solution
        3. Discussion
      11. Working with Roman Numerals
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. Formatting with Correct Plurals
        1. Problem
        2. Solution
      13. Generating Random Numbers
        1. Problem
        2. Solution
        3. See Also
      14. Generating Better Random Numbers
        1. Problem
        2. Solution
        3. See Also
      15. Calculating Trigonometric Functions
        1. Problem
        2. Solution
      16. Taking Logarithms
        1. Problem
        2. Solution
        3. Discussion
      17. Multiplying Matrixes
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      18. Using Complex Numbers
        1. Problem
        2. Solution
      19. Handling Very Large Numbers
        1. Problem
        2. Solution
        3. Discussion
      20. Program: TempConverter
      21. Program: Number Palindromes
        1. See Also
    7. 6. Dates and Times
      1. Introduction
      2. Finding Today’s Date
        1. Problem
        2. Solution
        3. Discussion
      3. Printing Date/Time in a Specified Format
        1. Problem
        2. Solution
        3. Discussion
      4. Representing Dates in Other Epochs
        1. Problem
        2. Solution
        3. Discussion
      5. Converting YMDHMS to a Calendar or Epoch Seconds
        1. Problem
        2. Solution
      6. Parsing Strings into Dates
        1. Problem
        2. Solution
        3. Discussion
      7. Converting Epoch Seconds to DMYHMS
        1. Problem
        2. Solution
        3. Discussion
      8. Adding to or Subtracting from a Date or Calendar
        1. Problem
        2. Solution
        3. Discussion
      9. Difference Between Two Dates
        1. Problem
        2. Solution
        3. Discussion
      10. Comparing Dates
        1. Problem
        2. Solution
        3. Discussion
      11. Day of Week/Month/Year or Week Number
        1. Problem
        2. Solution
        3. Discussion
      12. Calendar Page
        1. Problem
        2. Solution
        3. Discussion
      13. High-Resolution Timers
        1. Problem
        2. Solution
        3. Discussion
      14. Sleeping for a While
        1. Problem
        2. Solution
        3. Discussion
      15. Program: Reminder Service
        1. See Also
    8. 7. Structuring Data with Java
      1. Introduction
      2. Data Structuring Using Arrays
        1. Problem
        2. Solution
        3. Discussion
      3. Resizing an Array
        1. Problem
        2. Solution
        3. Discussion
      4. Like an Array, but More Dynamic
        1. Problem
        2. Solution
        3. Discussion
      5. Data-Independent Access with Iterators
        1. Problem
        2. Solution
        3. Discussion
      6. Structuring Data in a Linked List
        1. Problem
        2. Solution
        3. Discussion
      7. Mapping with Hashtable and HashMap
        1. Problem
        2. Solution
        3. Discussion
      8. Storing Strings in Properties and Preferences
        1. Problem
        2. Solution
        3. Discussion
      9. Sorting a Collection
        1. Problem
        2. Solution
        3. Discussion
      10. Sorting in Java 1.1
        1. Problem
        2. Solution
        3. Discussion
      11. Avoiding the Urge to Sort
        1. Problem
        2. Solution
        3. Discussion
      12. Sets
        1. Problem
        2. Solution
        3. Discussion
      13. Finding an Object in a Collection
        1. Problem
        2. Solution
        3. Discussion
      14. Converting a Collection to an Array
        1. Problem
        2. Solution
        3. Discussion
      15. Rolling Your Own Iterator
        1. Problem
        2. Solution
        3. Discussion
      16. Stack
        1. Problem
        2. Solution
        3. Discussion
      17. Multidimensional Structures
        1. Problem
        2. Solution
        3. Discussion
      18. Finally, Collections
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      19. Program: Timing Comparisons
    9. 8. Object-Oriented Techniques
      1. Introduction
        1. Advice, or Mantras
          1. Use the API
          2. Generalize
          3. Read and write Javadoc
          4. Subclass early and often
          5. Use design patterns
      2. Printing Objects: Formatting with toString( )
        1. Problem
        2. Solution
        3. Discussion
      3. Overriding the Equals Method
        1. Problem
        2. Solution
        3. Discussion
      4. Overriding the Hashcode Method
        1. Problem
        2. Discussion
      5. The Clone Method
        1. Problem
        2. Solution
        3. Discussion
          1. Using cloning
          2. Difficulty in the standard API
      6. The Finalize Method
        1. Problem
        2. Solution
        3. Discussion
      7. Using Inner Classes
        1. Problem
        2. Solution
        3. Discussion
      8. Providing Callbacks via Interfaces
        1. Problem
        2. Solution
        3. Discussion
      9. Polymorphism/Abstract Methods
        1. Problem
        2. Solution
        3. Discussion
      10. Passing Values
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. Roll Your Own Exceptions
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. Program: Plotter
    10. 9. Input and Output
      1. Introduction
        1. Correcting Misconceptions
        2. Streams and Readers/Writers
        3. See Also
      2. Reading Standard Input
        1. Problem
        2. Solution
        3. Discussion
      3. Writing Standard Output
        1. Problem
        2. Solution
        3. Discussion
      4. Opening a File by Name
        1. Problem
        2. Solution
        3. Discussion
      5. Copying a File
        1. Problem
        2. Solution
        3. Discussion
      6. Reading a File into a String
        1. Problem
        2. Solution
        3. Discussion
      7. Reassigning the Standard Streams
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Duplicating a Stream as It Is Written
        1. Problem
        2. Solution
        3. Discussion
      9. Reading/Writing a Different Character Set
        1. Problem
        2. Solution
        3. Discussion
      10. Those Pesky End-of-Line Characters
        1. Problem
        2. Solution
        3. Discussion
      11. Beware Platform-Dependent File Code
        1. Problem
        2. Solution
        3. Discussion
      12. Reading “Continued” Lines
        1. Problem
        2. Solution
        3. Discussion
      13. Scanning a File
        1. Problem
        2. Solution
        3. Discussion
      14. Binary Data
        1. Problem
        2. Solution
        3. Discussion
      15. Seeking
        1. Problem
        2. Solution
        3. Discussion
      16. Writing Data Streams from C
        1. Problem
        2. Solution
        3. Discussion
      17. Saving and Restoring Serialized Objects
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      18. Preventing ClassCastExceptions with SerialVersionUID
        1. Problem
        2. Solution
        3. Discussion
      19. Reading and Writing JAR or Zip Archives
        1. Problem
        2. Solution
        3. Discussion
      20. Reading and Writing Compressed Files
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      21. Program: Text to PostScript
        1. See Also
      22. Program: TarList (File Converter)
        1. See Also
    11. 10. Directory and Filesystem Operations
      1. Introduction
      2. Getting File Information
        1. Problem
        2. Solution
        3. Discussion
      3. Creating a File
        1. Problem
        2. Solution
        3. Discussion
      4. Renaming a File
        1. Problem
        2. Solution
        3. Discussion
      5. Deleting a File
        1. Problem
        2. Solution
        3. Discussion
      6. Creating a Transient File
        1. Problem
        2. Solution
        3. Discussion
      7. Changing File Attributes
        1. Problem
        2. Solution
        3. Discussion
      8. Listing a Directory
        1. Problem
        2. Solution
        3. Discussion
      9. Getting the Directory Roots
        1. Problem
        2. Solution
        3. Discussion
      10. Making New Directories
        1. Problem
        2. Solution
        3. Discussion
      11. Program: Find
    12. 11. Programming Serial and Parallel Ports
      1. Introduction
        1. The Communications API
        2. About the Code Examples in This Chapter
        3. See Also
      2. Choosing a Port
        1. Problem
        2. Solution
        3. Discussion
      3. Opening a Serial Port
        1. Problem
        2. Solution
        3. Discussion
      4. Opening a Parallel Port
        1. Problem
        2. Solution
        3. Discussion
      5. Resolving Port Conflicts
        1. Problem
        2. Solution
        3. Discussion
      6. Reading and Writing: Lock Step
        1. Problem
        2. Solution
        3. Discussion
      7. Reading and Writing: Event-Driven
        1. Problem
        2. Solution
        3. Discussion
      8. Reading and Writing: Threads
        1. Problem
        2. Solution
        3. Discussion
      9. Program: Penman Plotter
        1. See Also
    13. 12. Graphics and Sound
      1. Introduction
      2. Painting with a Graphics Object
        1. Problem
        2. Solution
        3. Discussion
          1. When to draw?
      3. Testing Graphical Components
        1. Problem
        2. Solution
        3. Discussion
      4. Drawing Text
        1. Problem
        2. Solution
      5. Drawing Centered Text in a Component
        1. Problem
        2. Solution
        3. Discussion
      6. Drawing a Drop Shadow
        1. Problem
        2. Solution
        3. Discussion
      7. Drawing an Image
        1. Problem
        2. Solution
        3. Discussion
      8. Playing a Sound File
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. Displaying a Moving Image with Video
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Drawing Text with 2D
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. Printing: JDK 1.1
        1. Problem
        2. Solution
        3. Discussion
      12. Printing: Java 2
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. Program: PlotterAWT
      14. Program: Grapher
    14. 13. Graphical User Interfaces
      1. Introduction
      2. Displaying GUI Components
        1. Problem
        2. Solution
        3. Discussion
      3. Designing a Window Layout
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. A Tabbed View of Life
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Action Handling: Making Buttons Work
        1. Problem
        2. Solution
        3. Discussion
      6. Action Handling Using Anonymous Inner Classes
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Terminating a Program with “Window Close”
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Dialogs: When Later Just Won’t Do
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. Getting Program Output into a Window
        1. Problem
        2. Solution
        3. Discussion
      10. Choosing a File with JFileChooser
        1. Problem
        2. Solution
        3. Discussion
      11. Choosing a Color
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. Centering a Main Window
        1. Problem
        2. Solution
        3. Discussion
      13. Changing a Swing Program’s Look and Feel
        1. Problem
        2. Solution
        3. Discussion
      14. Program: Custom Font Chooser
        1. Problem
        2. Solution
        3. Discussion
      15. Program: Custom Layout Manager
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    15. 14. Internationalization and Localization
      1. Introduction
      2. Creating a Button with I18N Resources
        1. Problem
        2. Solution
          1. What happens at runtime?
          2. Setting the locale
      3. Listing Available Locales
        1. Problem
        2. Solution
        3. Discussion
      4. Creating a Menu with I18N Resources
        1. Problem
        2. Solution
        3. Discussion
      5. Writing Internationalization Convenience Routines
        1. Problem
        2. Solution
        3. Discussion
      6. Creating a Dialog with I18N Resources
        1. Problem
        2. Solution
        3. Discussion
      7. Creating a Resource Bundle
        1. Problem
        2. Solution
        3. Discussion
      8. JILTing Your Code
      9. Using a Particular Locale
        1. Problem
        2. Solution
        3. Discussion
      10. Setting the Default Locale
        1. Problem
        2. Solution
        3. Discussion
      11. Formatting Messages
        1. Problem
        2. Solution
        3. Discussion
      12. Program: MenuIntl
      13. Program: BusCard
        1. See Also
        2. Internationalization Caveats
        3. Documentation
        4. The Last Word
    16. 15. Network Clients
      1. Introduction
      2. Contacting a Server
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Finding and Reporting Network Addresses
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Handling Network Errors
        1. Problem
        2. Solution
      5. Reading and Writing Textual Data
        1. Problem
        2. Solution
        3. Discussion
      6. Reading and Writing Binary Data
        1. Problem
        2. Solution
        3. Discussion
      7. Reading and Writing Serialized Data
        1. Problem
        2. Solution
        3. Discussion
      8. UDP Datagrams
        1. Problem
        2. Solution
        3. Discussion
      9. Program: TFTP UDP Client
      10. Program: Telnet Client
      11. Program: Chat Client
        1. See Also
    17. 16. Server-Side Java: Sockets
      1. Introduction
      2. Opening a Server for Business
        1. Problem
        2. Solution
        3. Discussion
      3. Returning a Response (String or Binary)
        1. Problem
        2. Solution
        3. Discussion
      4. Returning Object Information
        1. Problem
        2. Solution
        3. Discussion
      5. Handling Multiple Clients
        1. Problem
        2. Solution
        3. Discussion
      6. Network Logging
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Program: A Java Chat Server
        1. See Also
    18. 17. Network Clients II: Applets and Web Clients
      1. Introduction
      2. Embedding Java in a Web Page
        1. Problem
        2. Solution
        3. Discussion
      3. Applet Techniques
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Contacting a Server on the Applet Host
        1. Problem
        2. Solution
        3. Discussion
      5. Making an Applet Show a Document
        1. Problem
        2. Solution
        3. Discussion
      6. Making an Applet Run a CGI Script
        1. Problem
        2. Solution
        3. Discussion
      7. Reading the Contents of a URL
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Extracting HTML from a URL
        1. Problem
        2. Solution
        3. Discussion
      9. Extracting URLs from a File
        1. Problem
        2. Solution
        3. Discussion
      10. Converting a Filename to a URL
        1. Problem
        2. Solution
        3. Discussion
      11. Program: MkIndex
      12. Program: LinkChecker
        1. Downloading an Entire Web Site
    19. 18. Web Server Java: Servlets and JSP
      1. Introduction
      2. First Servlet: Generating an HTML Page
        1. Problem
        2. Solution
        3. Discussion
      3. Servlets: Processing Form Parameters
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Cookies
        1. Problem
        2. Solution
        3. Discussion
      5. Session Tracking
        1. Problem
        2. Solution
        3. Discussion
      6. Generating PDF from a Servlet
        1. Problem
        2. Solution
        3. Discussion
      7. HTML Meets Java: JSP
        1. Problem
        2. Solution
        3. Discussion
      8. JSP Include/Forward
        1. Problem
        2. Solution
        3. Discussion
      9. JavaServer Pages Using a Servlet
        1. Problem
        2. Solution
        3. Discussion
      10. Simplifying Your JSP with a JavaBean
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. JSP Syntax Summary
        1. Problem
        2. Solution
        3. Discussion
      12. Program: CookieCutter
      13. Program: JabaDot Web News Portal
        1. See Also
    20. 19. Java and Electronic Mail
      1. Introduction
      2. Sending Email: Browser Version
        1. Problem
        2. Solution
        3. Discussion
      3. Sending Email: For Real
        1. Problem
        2. Solution
        3. Discussion
      4. Mail-Enabling a Server Program
        1. Problem
        2. Solution
        3. Discussion
      5. Sending MIME Mail
        1. Problem
        2. Solution
        3. Discussion
      6. Providing Mail Settings
        1. Problem
        2. Solution
        3. Discussion
      7. Sending Mail Without Using JavaMail
        1. Problem
        2. Solution
        3. Discussion
      8. Reading Email
        1. Problem
        2. Solution
        3. Discussion
      9. Program: MailReaderBean
      10. Program: MailClient
        1. See Also
    21. 20. Database Access
      1. Introduction
      2. Text-File Databases
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. DBM Databases
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. JDBC Setup and Connection
        1. Problem
        2. Solution
        3. Discussion
      5. Connecting to a JDBC Database
        1. Problem
        2. Solution
        3. Discussion
      6. Sending a JDBC Query and Getting Results
        1. Problem
        2. Solution
        3. Discussion
      7. Using JDBC Parameterized Statements
        1. Problem
        2. Solution
        3. Discussion
      8. Using Stored Procedures with JDBC
        1. Problem
        2. Solution
        3. Discussion
      9. Changing Data Using a ResultSet
        1. Problem
        2. Solution
        3. Discussion
      10. Changing Data Using SQL
        1. Problem
        2. Solution
        3. Discussion
      11. Finding JDBC Metadata
        1. Problem
        2. Solution
        3. Discussion
          1. Database metadata
      12. Program: JDAdmin
        1. See Also
    22. 21. XML
      1. Introduction
      2. Transforming XML with XSLT
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Parsing XML with SAX
        1. Problem
        2. Solution
        3. Discussion
      4. Parsing XML with DOM
        1. Problem
        2. Solution
        3. Discussion
      5. Verifying Structure with a DTD
        1. Problem
        2. Solution
        3. Discussion
      6. Generating Your Own XML with DOM
        1. Problem
        2. Solution
        3. Discussion
      7. Program: xml2mif
        1. See Also
    23. 22. Distributed Java: RMI
      1. Introduction
      2. Defining the RMI Contract
        1. Problem
        2. Solution
        3. Discussion
      3. RMI Client
        1. Problem
        2. Solution
        3. Discussion
      4. RMI Server
        1. Problem
        2. Solution
        3. Discussion
          1. Using the server
        4. See Also
      5. Deploying RMI Across a Network
        1. Problem
        2. Solution
        3. Discussion
      6. Program: RMI Callbacks
      7. Program: RMIWatch
        1. See Also
    24. 23. Packages and Packaging
      1. Introduction
      2. Creating a Package
        1. Problem
        2. Solution
        3. Discussion
      3. Documenting Classes with Javadoc
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Archiving with jar
        1. Problem
        2. Solution
        3. Discussion
      5. Running an Applet from a JAR
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Running an Applet with a JDK
        1. Problem
        2. Solution
        3. Discussion
      7. Running a Program from a JAR
        1. Problem
        2. Solution
        3. Discussion
      8. Preparing a Class as a JavaBean
        1. Problem
        2. Solution
        3. Discussion
      9. Pickling Your Bean into a JAR
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Packaging a Servlet into a WAR File
        1. Problem
        2. Solution
        3. Discussion
      11. “Write Once, Install Anywhere”
        1. Problem
        2. Solution
        3. Discussion
      12. Java Web Start
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. Signing Your JAR File
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    25. 24. Threaded Java
      1. Introduction
      2. Running Code in a Different Thread
        1. Problem
        2. Solution
        3. Discussion
          1. Thread life cycle methods
      3. Displaying a Moving Image with Animation
        1. Problem
        2. Solution
        3. Discussion
      4. Stopping a Thread
        1. Problem
        2. Solution
        3. Discussion
      5. Rendezvous and Timeouts
        1. Problem
        2. Solution
        3. Discussion
      6. Thread Communication: Synchronized Code
        1. Problem
        2. Solution
        3. Discussion
      7. Thread Communication: wait( ) and notifyAll( )
        1. Problem
        2. Solution
        3. Discussion
      8. Background Saving in an Editor
        1. Problem
        2. Solution
        3. Discussion
      9. Threaded Network Server
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    26. 25. Introspection, or “A Class Named Class”
      1. Introduction
      2. Getting a Class Descriptor
        1. Problem
        2. Solution
      3. Finding and Using Methods and Fields
        1. Problem
        2. Solution
        3. Discussion
      4. Loading and Instantiating a Class Dynamically
        1. Problem
        2. Solution
        3. Discussion
      5. Constructing a Class from Scratch
        1. Problem
        2. Solution
        3. Discussion
          1. What next?
      6. Performance Timing
        1. Problem
        2. Solution
        3. Discussion
          1. Timing results
          2. Timing program
      7. Printing Class Information
        1. Problem
        2. Solution
        3. Discussion
      8. Program: CrossRef
      9. Program: AppletViewer
        1. See Also
    27. 26. Using Java with Other Languages
      1. Introduction
      2. Running a Program
        1. Problem
        2. Solution
        3. Discussion
      3. Running a Program and Capturing Its Output
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Mixing Java and Scripts with BSF
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Blending in Native Code (C/C++)
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Calling Java from Native Code
        1. Problem
        2. Solution
        3. Discussion
      7. Program: DBM
        1. See Also
    28. 27. Afterword
    29. Index
    30. Colophon