The JavaTM Tutorial


The Really Big Index
A list of all content pages in the The JavaTM Tutorial

Here's a list of all of the trails in The Java Tutorial. Each item in this list links to the location on this page where a particular trail's lessons and pages are listed in order.

Trails published in The Java Tutorial Third Edition:

Trails published in The JFC Swing Tutorial:

Trail: Getting Started

The Java Technology Phenomenon
About the Java Technology
What Can Java Technology Do?
How Will Java Technology Change My Life?
The "Hello World!" Application
"Hello World!" for the NetBeans IDE
"Hello World!" for Microsoft Windows
"Hello World!" for Solaris OS and Linux
A Closer Look at the "Hello World!" Application
Questions and Exercises: Getting Started
Common Problems (and Their Solutions)

Trail: Learning the Java Language

Object-Oriented Programming Concepts
What Is an Object?
What Is a Class?
What Is Inheritance?
What Is an Interface?
What Is a Package?
Questions and Exercises: Object-Oriented Programming Concepts
Language Basics
Variables
    Primitive Data Types
    Arrays
    Summary of Variables
    Questions and Exercises: Variables
Operators
    Assignment, Arithmetic, and Unary Operators
    Equality, Relational, and Conditional Operators
    Bitwise and Bit Shift Operators
    Summary of Operators
    Questions and Exercises: Operators
Expressions, Statements, and Blocks
Questions and Exercises: Expressions, Statements, and Blocks
Control Flow Statements
    The if-then and if-then-else Statements
    The switch Statement
    The while and do-while Statements
    The for Statement
    Branching Statements
    Summary of Control Flow Statements
    Questions and Exercises: Control Flow Statements
Classes and Objects
Classes
    Declaring Classes
    Declaring Member Variables
    Defining Methods
    Providing Constructors for Your Classes
    Passing Information to a Method or a Constructor
Objects
    Creating Objects
    Using Objects
More on Classes
    Returning a Value from a Method
    Using the this Keyword
    Controlling Access to Members of a Class
    Understanding Instance and Class Members
    Initializing Fields
    Summary of Creating and Using Classes and Objects
    Questions and Exercises: Classes
    Questions and Exercises: Objects
Nested Classes
    Inner Class Example
    Summary of Nested Classes
    Questions and Exercises: Nested Classes
Enum Types
Questions and Exercises: Enum Types
Annotations
Questions and Exercises: Annotations
Interfaces and Inheritance
Interfaces
    Defining an Interface
    Implementing an Interface
    Using an Interface as a Type
    Rewriting Interfaces
    Summary of Interfaces
    Questions and Exercises: Interfaces
Inheritance
    Overriding and Hiding Methods
    Hiding Fields
    Using the Keyword super
    Object as a Superclass
    Writing Final Classes and Methods
    Abstract Methods and Classes
    Summary of Inheritance
    Questions and Exercises: Inheritance
Numbers and Strings
Numbers
    The Numbers Classes
    Formatting Numeric Print Output
    Beyond Basic Arithmetic
    Summary of Numbers
    Questions and Exercises: Numbers
Characters
Strings
    Converting Between Numbers and Strings
    Manipulating Characters in a String
    Comparing Strings and Portions of Strings
    The StringBuilder Class
    Summary of Characters and Strings
    Questions and Exercises: Characters and Strings
Generics
Introduction
Generic Types
Generic Methods and Constructors
Bounded Type Parameters
Subtyping
Wildcards
Type Erasure
Summary of Generics
Questions and Exercises: Generics
Packages
Creating and Using Packages
    Creating a Package
    Naming a Package
    Using Package Members
    Managing Source and Class Files
    Summary of Creating and Using Packages
    Questions and Exercises: Creating and Using Packages
Solving Common Coding Problems

Trail: Essential Classes

Exceptions
What Is an Exception?
The Catch or Specify Requirement
Catching and Handling Exceptions
    The try Block
    The catch Blocks
    The finally Block
    Putting It All Together
Specifying the Exceptions Thrown by a Method
How to Throw Exceptions
    Chained Exceptions
    Creating Exception Classes
Unchecked Exceptions — The Controversy
Advantages of Exceptions
Summary
Questions and Exercises
Basic I/O
I/O Streams
    Byte Streams
    Character Streams
    Buffered Streams
    Scanning and Formatting
        Scanning
        Formatting
    I/O from the Command Line
    Data Streams
    Object Streams
File I/O
    File Objects
    Random Access Files
The New I/O Packages
Summary
Questions and Exercises: Basic I/O
Concurrency
Processes and Threads
Thread Objects
    Defining and Starting a Thread
    Pausing Execution with Sleep
    Interrupts
    Joins
    The SimpleThreads Example
Synchronization
    Thread Interference
    Memory Consistency Errors
    Synchronized Methods
    Intrinsic Locks and Synchronization
    Atomic Access
Liveness
    Deadlock
    Starvation and Livelock
Guarded Blocks
Immutable Objects
    A Synchronized Class Example
    A Strategy for Defining Immutable Objects
High Level Concurrency Objects
    Lock Objects
    Executors
        Executor Interfaces
        Thread Pools
    Concurrent Collections
    Atomic Variables
For Further Reading
Questions and Exercises: Concurrency
The Platform Environment
Configuration Utilities
    Properties
    Command-Line Arguments
    Environment Variables
    Other Configuration Utilities
System Utilities
    Command-Line I/O Objects
    System Properties
    The Security Manager
    Miscellaneous Methods in System
PATH and CLASSPATH
Questions and Exercises: The Platform Environment
Regular Expressions
Introduction
Test Harness
String Literals
Character Classes
Predefined Character Classes
Quantifiers
Capturing Groups
Boundary Matchers
Methods of the Pattern Class
Methods of the Matcher Class
Methods of the PatternSyntaxException Class
Additional Resources
Questions and Exercises: Regular Expressions

Trail: Deployment

Packaging Programs in JAR Files
Using JAR Files: The Basics
    Creating a JAR File
    Viewing the Contents of a JAR File
    Extracting the Contents of a JAR File
    Updating a JAR File
    Running JAR-Packaged Software
Working with Manifest Files: The Basics
    Understanding the Default Manifest
    Modifying a Manifest File
    Setting an Application's Entry Point
    Adding Classes to the JAR File's Classpath
    Setting Package Version Information
    Sealing Packages within a JAR File
Signing and Verifying JAR Files
    Understanding Signing and Verification
    Signing JAR Files
    Verifying Signed JAR Files
Using JAR-related APIs
    The JarClassLoader Class
    The JarRunner Class
Java Web Start
Running Java Web Start Applications
Deploying Java Web Start Applications
Developing Java Web Start Applications
The JNLP API
Java Web Start and Security
Common Java Web Start Problems
Questions and Exercises: Java Web Start
Applets
Getting Started with Applets
    Importing Classes and Packages for Applets
    Defining an Applet Subclass
    The Life Cycle of an Applet
    Methods for Milestones
    Methods for Drawing and Event Handling
    Methods for Adding UI Components
    What Applets Can and Can't Do
Taking Advantage of the Applet API
    Finding and Loading Data Files
    Displaying Short Status Strings
    Displaying Documents in the Browser
    Sending Messages to Other Applets
    Playing Sounds
    Defining and Using Applet Parameters
        Deciding Which Parameters to Support
        Writing the Code to Support Parameters
        Giving Information about Parameters
    Using the APPLET Tag
Practical Considerations When Writing Applets
    Security Restrictions
    Creating a User Interface
        Creating a GUI
        Displaying Diagnostics to the Standard Output and Error Streams
    Getting System Properties
    Threads in Applets
        Threads in Applets: Examples
    Working with a Server-Side Application
        A Simple Network Client Applet
        Using a Server to Work Around Security Restrictions
Finishing an Applet
    Before You Ship that Applet
    The Perfectly Finished Applet
Deploying Applets
    General Deployment Considerations
    Using the applet Tag
    Using the object Tag
    Using the embed Tag
    Deploying Applets in a Mixed-Browser Environment
Solving Common Applet Problems
Questions and Exercises: Java Applets

Trail: Graphical User Interfaces

A Brief Introduction to the Swing Package
What is Swing?
A Swing Demo
Swing Features
A Visual Guide to Swing Components (Java Look and Feel)
A Visual Guide to Swing Components (Windows Look and Feel)
Pluggable Look and Feel
Internationalization and Localization
Accessibility
Integrating with the Desktop
System Tray Icon Support
Questions and Exercises: Graphical User Interfaces

Trail: Creating a GUI with JFC/Swing

Getting Started with Swing
About the JFC and Swing
Compiling and Running Swing Programs
Learning Swing by Example
Example One: Your First Swing Program
Example Two: SwingApplication
Example Three: CelsiusConverter
Example Four: An Improved CelsiusConverter
Example Five: LunarPhases
Example Six: VoteDialog
Summary
Questions and Exercises: Learning Swing by Example
Using Swing Components
A Visual Index to the Swing Components
Using HTML in Swing Components
Using Top-Level Containers
Using Models
The JComponent Class
Using Text Components
    Text Component Features
    The Text Component API
How to Use Various Components
    How to Make Applets
    How to Use Buttons, Check Boxes, and Radio Buttons
    How to Use Color Choosers
    How to Use Combo Boxes
    How to Make Dialogs
    How to Use Editor Panes and Text Panes
    How to Use File Choosers
    How to Use Formatted Text Fields
    How to Make Frames (Main Windows)
    How to Use Internal Frames
    How to Use Labels
    How to Use Layered Panes
    How to Use Lists
    How to Use Menus
    How to Use Panels
    How to Use Password Fields
    How to Use Progress Bars
    How to Use Root Panes
    How to Use Scroll Panes
    How to Use Separators
    How to Use Sliders
    How to Use Spinners
    How to Use Split Panes
    How to Use Tabbed Panes
    How to Use Tables
    How to Use Text Areas
    How to Use Text Fields
    How to Use Tool Bars
    How to Use Tool Tips
    How to Use Trees
How to Use Icons
How to Use Borders
Solving Common Component Problems
Questions and Exercises: Using Swing Components
Concurrency in Swing
Initial Threads
The Event Dispatch Thread
Worker Threads and SwingWorker
    Simple Background Tasks
    Tasks that Have Interim Results
    Canceling Background Tasks
    Bound Properties and Status Methods
    Questions and Exercises: Concurrency in Swing
Using Other Swing Features
How to Use Actions
How to Use Swing Timers
How to Support Assistive Technologies
How to Use the Focus Subsystem
How to Use Key Bindings
Solving Common Problems Using Other Swing Features
Laying Out Components Within a Container
A Visual Guide to Layout Managers
Using Layout Managers
How Layout Management Works
How to Use Various Layout Managers
How to Use BorderLayout
How to Use BoxLayout
How to Use CardLayout
How to Use FlowLayout
How to Use GridBagLayout
How to Use GridLayout
How to Use GroupLayout
    A GroupLayout Example
How to Use SpringLayout
Creating a Custom Layout Manager
Doing Without a Layout Manager (Absolute Positioning)
Solving Common Layout Problems
Questions and Exercises: Laying Out Components within a Container
Modifying the Look and Feel
How to Set the Look and Feel
Drag and Drop and Data Transfer
Introduction to Drag and Drop and Data Transfer
Writing Event Listeners
Introduction to Event Listeners
General Information about Writing Event Listeners
Listeners Supported by Swing Components
Implementing Listeners for Commonly Handled Events
    How to Write an Action Listener
    How to Write a Caret Listener
    How to Write a Change Listener
    How to Write a Component Listener
    How to Write a Container Listener
    How to Write a Document Listener
    How to Write a Focus Listener
    How to Write an Internal Frame Listener
    How to Write an Item Listener
    How to Write a Key Listener
    How to Write a List Data Listener
    How to Write a List Selection Listener
    How to Write a Mouse Listener
    How to Write a Mouse-Motion Listener
    How to Write a Mouse-Wheel Listener
    How to Write a Property Change Listener
    How to Write a Table Model Listener
    How to Write a Tree Expansion Listener
    How to Write a Tree Model Listener
    How to Write a Tree Selection Listener
    How to Write a Tree-Will-Expand Listener
    How to Write an Undoable Edit Listener
    How to Write Window Listeners
Listener API Table
Solving Common Event-Handling Problems
Questions and Exercises: Writing Event Listeners
Performing Custom Painting
How Swing Components Are Displayed
Introduction to Painting Concepts
Implementing a Custom Component
Summary
Solving Common Painting Problems
Questions and Exercises: Performing Custom Painting

Trail: Collections

Introduction to Collections
Interfaces
The Collection Interface
The Set Interface
The List Interface
The Queue Interface
The Map Interface
Object Ordering
The SortedSet Interface
The SortedMap Interface
Summary of Interfaces
Questions and Exercises: Interfaces
Implementations
Set Implementations
List Implementations
Map Implementations
Queue Implementations
Wrapper Implementations
Convenience Implementations
Summary of Implementations
Questions and Exercises: Implementations
Algorithms
Custom Collection Implementations
Interoperability
Compatibility
API Design

Trail: Internationalization

Introduction
A Quick Example
    Before Internationalization
    After Internationalization
    Running the Sample Program
    Internationalizing the Sample Program
Checklist
Setting the Locale
Creating a Locale
Identifying Available Locales
The Scope of a Locale
Locale-Sensitive Services SPI
Isolating Locale-Specific Data
About the ResourceBundle Class
Preparing to Use a ResourceBundle
Backing a ResourceBundle with Properties Files
Using a ListResourceBundle
Customizing Resource Bundle Loading
Formatting
Numbers and Currencies
    Using Predefined Formats
    Customizing Formats
Dates and Times
    Using Predefined Formats
    Customizing Formats
    Changing Date Format Symbols
Messages
    Dealing with Compound Messages
    Handling Plurals
Working with Text
Checking Character Properties
Comparing Strings
    Performing Locale-Independent Comparisons
    Customizing Collation Rules
    Improving Collation Performance
Detecting Text Boundaries
    About the BreakIterator Class
    Character Boundaries
    Word Boundaries
    Sentence Boundaries
    Line Boundaries
Converting Non-Unicode Text
    Byte Encodings and Strings
    Character and Byte Streams
Normalizer's API
Internationalization of Network Resources
Internationalized Domain Name
Internationalized Resource Identifier

Trail: 2D Graphics

Overview of the Java 2D API Concepts
Coordinates
Java 2D Rendering
Geometric Primitives
Text
Images
Printing
Getting Started with Graphics
Working with Geometry
Drawing Geometric Primitives
Drawing Arbitrary Shapes
Stroking and Filling Graphics Primitives
Working with Text APIs
Selecting a Font
Measuring Text
Advanced Text Display
    Displaying Antialiased Text by Using Rendering Hints
    Using Text Attributes to Style Text
    Drawing Multiple Lines of Text
Working with Images
Reading/Loading an Image
Drawing an Image
Creating and Drawing to an Image
Writing/Saving an Image
Printing
A Basic Printing Program
Using Print Setup Dialogs
Printing a Multiple Page Document
Working with Print Services and Attributes
Printing the Contents of a User Interface
Printing Support in Swing Components
Advanced Topics in Java2D
Transforming Shapes, Text, and Images
Clipping the Drawing Region
Compositing Graphics
Controlling Rendering Quality
Constructing Complex Shapes from Geometry Primitives
Supporting User Interaction

Trail: Sound

Overview of the Sampled Package
Accessing Audio System Resources
Playing Back Audio
Capturing Audio
Processing Audio with Controls
Using Files and Format Converters
Overview of the MIDI Package
Accessing MIDI System Resources
Transmitting and Receiving MIDI Messages
Introduction to Sequencers
Using Sequencer Methods
Using Advanced Sequencer Features
Synthesizing Sound
Introduction to the Service Provider Interfaces
Providing Sampled-Audio Services
Providing MIDI Services

Trail: JavaBeans(TM)

JavaBeans Concepts
Using the NetBeans GUI Builder
Writing a Simple Bean
Properties
Simple Properties
Bound Properties
Constrained Properties
Indexed Properties
Manipulating Events
Bean Persistence
Long Term Persistence
Introspection
Bean Customization
Using the BeanContext API
Overview of the BeanContext API
Bean Context #1: Containment Only
Bean Context #2: Containment and Services
AWT Containers and the BeanContextProxy Interface

Trail: JDBC(TM) Database Access

JDBC Introduction
JDBC Architecture
A Relational Database Overview
JDBC Basics
Getting Started
Setting Up a Database
Establishing a Connection
Setting Up Tables
Retrieving Values from Result Sets
Updating Tables
Milestone: The Basics of JDBC
Using Prepared Statements
Using Joins
Using Transactions
Stored Procedures
SQL Statements for Creating a Stored Procedure
Creating Complete JDBC Applications
Running the Sample Applications
Creating an Applet from an Application

Trail: Java Management Extensions (JMX)

Overview of the JMX Technology
Why Use the JMX Technology?
Architecture of the JMX Technology
Monitoring and Management of the Java Virtual Machine
Introducing MBeans
Standard MBeans
MXBeans
Notifications
Remote Management
Exposing a Resource for Remote Management By JConsole
Creating a Custom JMX Client

Trail: RMI

An Overview of RMI Applications
Writing an RMI Server
    Designing a Remote Interface
    Implementing a Remote Interface
Creating a Client Program
Compiling and Running the Example
    Compiling the Example Programs
    Running the Example Programs

Trail: Security Features in Java SE

Security Features Overview
Quick Tour of Controlling Applets
Observe Applet Restrictions
Set up a Policy File to Grant the Required Permission
    Start Policy Tool
    Grant the Required Permission
    Save the Policy File
See the Policy File Effects
Quick Tour of Controlling Applications
Observe Application Freedom
See How to Restrict Applications
Set up the Policy File to Grant the Required Permissions
    Open the Policy File
    Grant the Required Permissions
    Save the Policy File
See the Policy File Effects
API and Tools Use for Secure Code and File Exchanges
Signing Code and Granting It Permissions
Steps for the Code Signer
    Download and Try the Sample Application
    Create a JAR File Containing the Class File
    Generate Keys
    Sign the JAR File
    Export the Public Key Certificate
Steps for the Code Receiver
    Observe the Restricted Application
    Import the Certificate as a Trusted Certificate
    Set Up a Policy File to Grant the Required Permission
        Start Policy Tool
        Specify the Keystore
        Add a Policy Entry with a SignedBy Alias
        Save the Policy File
    See the Policy File Effects
Exchanging Files
Steps for the Contract Sender
    Create a JAR File Containing the Contract
    Generate Keys
    Sign the JAR File
    Export the Public Key Certificate
Steps for the Contract Receiver
    Import the Certificate as a Trusted Certificate
    Verify the JAR File Signature
Generating and Verifying Signatures
Generating a Digital Signature
    Prepare Initial Program Structure
    Generate Public and Private Keys
    Sign the Data
    Save the Signature and the Public Key in Files
    Compile and Run the Program
Verifying a Digital Signature
    Prepare Initial Program Structure
    Input and Convert the Encoded Public Key Bytes
    Input the Signature Bytes
    Verify the Signature
    Compile and Run the Program
Weaknesses and Alternatives
Implementing Your Own Permission
TerrysGame
The HighScore Class
The HighScorePermission Class
A Sample Policy File
Putting It All Together
    Steps for the HighScore Developer (Chris)
    Steps for the TerrysGame Developer (Terry)
    Steps for a User Running TerrysGame (Kim)

Trail: The Extension Mechanism

Creating and Using Extensions
Installed Extensions
Download Extensions
Understanding Extension Class Loading
Making Extensions Secure
Setting Privileges for Extensions
Sealing Packages in Extensions

Trail: The Reflection API

Examining Classes
Retrieving Class Objects
Getting the Class Name
Discovering Class Modifiers
Finding Superclasses
Identifying the Interfaces Implemented by a Class
Examining Interfaces
Identifying Class Fields
Discovering Class Constructors
Obtaining Method Information
Manipulating Objects
Creating Objects
    Using No-Argument Constructors
    Using Constructors that Have Arguments
Getting Field Values
Setting Field Values
Invoking Methods
Working with Arrays
Identifying Arrays
Retrieving Component Types
Creating Arrays
Getting and Setting Element Values
Summary of Classes

Trail: Custom Networking

Overview of Networking
What You May Already Know About Networking in Java
Networking Basics
Working with URLs
What Is a URL?
Creating a URL
Parsing a URL
Reading Directly from a URL
Connecting to a URL
Reading from and Writing to a URLConnection
All About Sockets
What Is a Socket?
Reading from and Writing to a Socket
Writing the Server Side of a Socket
All About Datagrams
What Is a Datagram?
Writing a Datagram Client and Server
Broadcasting to Multiple Recipients

Trail: Bonus

Generics
Introduction
Defining Simple Generics
Generics and Subtyping
Wildcards
Generic Methods
Interoperating with Legacy Code
The Fine Print
Class Literals as Runtime-Type Tokens
More Fun with Wildcards
Converting Legacy Code to Use Generics
Acknowledgements
Full-Screen Exclusive Mode API
Full-Screen Exclusive Mode
Display Mode
Passive vs. Active Rendering
Double Buffering and Page Flipping
BufferStrategy and BufferCapabilities
Examples
Preparation for Java Programmer Language Certification

Trail: Java Naming and Directory Interface(TM).

Naming and Directory Concepts
Directory Concepts
Overview of JNDI
Naming Package
Directory and LDAP Packages
Event and Service Provider Packages
Software Setup
LDAP Setup
Java Application Setup
Naming and Directory Operations
Naming Exceptions
Lookup an Object
List the Context
Add, Replace or Remove a Binding
Rename
Create and Destroy Subcontexts
Attribute Names
Read Attributes
Modify Attributes
Add, Replace Bindings with Attributes
Search
    Basic Search
    Filters
    Scope
    Result Count
    Time Limit
Trouble Shooting Tips
Advanced Topics for LDAP Users
LDAP v3
JNDI as an LDAP API
    How LDAP Operations Map to JNDI APIs
    How LDAP Error Codes Map to JNDI Exceptions
Security
    Modes of Authenticating to LDAP
    Authentication Mechanisms
    Anonymous
    Simple
    SASL
    Digest-MD5
    SSL and Custom Sockets
More LDAP Operations
    LDAP Compare
    Search Results
     LDAP Unsolicited Notifications
Connection Management
    Creation
     Closing
    Pooling
    Configuration
Frequently Asked Questions
Java Objects in the Directory
Storing and Reading Objects
Serializable Objects
New features in JDK 5.0 and JDK 6
Retrieving Distinguished Name
Standard LDAP Controls
Paged Results Control
Sort Control
Manage Referral Control
Manipulating LdapName (Distinguished Name)
Manipulating Relative Distringuished Name (RDN)
Setting Timeout for Ldap Operations

Trail: Drag and Drop