Table of Contents
Select one of the links below to reach the section in this Table of Contents for that trail.
Copyright
Getting Started
Writing Java Programs
Writing Applets
Creating a User Interface
The Java Development Environment
Integrating Native Methods into Java Programs
How the Java Language Differs from C and C++
Troubleshooting
Copyright
Getting Started
The "Hello World" Application
The "Hello World" Applet
Writing Java Programs
Object-Oriented Programming Concepts: A Primer
What is an Object?
What are Messages?
What are Classes?
What is Inheritance?
Where Can I Get More Information?
Java Objects
The Life Cycle of an Object
Creating an Object
Using an Object
Garbage Collection of Unused Objects
Creating Your Own Class
Declaring a Class
Implementing a Class
Writing a Method
Controlling Access to a Class's Methods
Declaring a Class Method
Declaring a Final Method
Declaring a Member Variable
Controlling Access to a Class's Variables
Declaring a Class Variable
Declaring a Constant
Declaring a Transient Variable
Declaring a Volatile Variable
Interfaces
The Anatomy of a Java Application
Comparison of DateApp and "Hello World"
Defining a Class
The main() Method
An Introduction to Java Objects
Declaring, Instantiating and Initializing an Object
Static vs. Instance
Saving, Compiling and Running an Application
The Nuts and Bolts of the Java Language
A Simple Class Definition
The main() Method
Introducing Exceptions
Variables and Data Types
Control Flow Statements
The Standard Input Stream
Operators
The Standard Output Stream
Character Data
Running the Application
The String and StringBuffer Classes
Why Two String Classes?
Creating Strings and StringBuffers
Accessor Methods
More Accessor Methods
Modifying StringBuffers
Converting Objects to Strings
Converting Strings to Numbers
Strings and the Java Compiler
Command Line Arguments
The Space Character Separates Command Line Arguments
Conventions
Parsing Command Line Arguments
Threads of Control
What Are Threads?
A Simple Thread Example
Thread Attributes
Thread Body
The Clock Applet
Thread State
Thread Priority
Daemon Threads
Thread Group
The ThreadGroup Class
Multithreaded Programs
Synchronization
Deadlock
Re-entrant Monitors
Summary
Input and Output Streams
Handling Errors using Exceptions
What's an Exception and Why Do I Care?
Your First Encounter with Java Exceptions
Java's Catch or Declare Requirement
Dealing with Exceptions
The Example
Catching and Handling Exceptions
The try Block
The catch Block(s)
The finally Block
Putting It All Together
Declaring the Exceptions Thrown by a Method
How to Throw Exceptions
The throw Statement
The Throwable Class and Its Subclasses
Creating Your Own Exception Classes
Runtime Exceptions--The Controversy
Writing Applets
Overview of Applets
The Life Cycle of an Applet
Methods for Milestones
Methods for Drawing and Event Handling
Using UI Components
Threads in Applets
Example
Saving, Compiling, and Running an Applet
Creating an Applet User Interface
Creating a GUI
Playing Sounds
Defining and Using Applet Parameters for Maximum Configurability
Reading System Properties
Displaying Short Status Strings
Displaying Diagnostics to the Standard Output
Communicating with Other Programs
Sending Messages to Other Applets
Working with a Server-Side Application
Other Communication
Understanding Applet Capabilities and Restrictions
Security Restrictions
What Can't Applets Do?
Working around Security Restrictions
Applet Capabilities
Before You Ship that Applet
Creating a User Interface
Overview of the Java UI
AWT Components
Other AWT Classes
The Anatomy of a GUI-Based Program
Classes in the Example Program
The Component Hierarchy
Drawing
Event Handling
Using Components, the GUI Building Blocks
Using the Standard Components
General Rules for Using Components
How to Use Buttons
How to Use Canvases
How to Use Checkboxes
How to Use Choices
How to Use Dialogs
How to Use Frames
How to Use Labels
How to Use Lists
How to Use Menus
How to Use Panels
How to Use Scrollbars
How to Use TextAreas
How to Use TextFields
Creating a Custom Component
Common Component Problems (and Their Solutions)
Laying Out Components within a Container
Using Layout Managers
General Rules for Using Layout Managers
How to Use BorderLayout
How to Use CardLayout
How to Use FlowLayout
How to Use GridLayout
How to Use GridBagLayout
Creating a Custom Layout Manager
Doing Without a Layout Manager (Absolute Positioning)
Common Layout Problems (and Their Solutions)
Drawing
Overview of Drawing
Graphics Primitives
Images
Using Graphics Primitives
Drawing Simple Shapes
Displaying Text
Using Images
Loading Images
Displaying Images
Manipulating Images
Improving Graphics Performance
Double Buffering
update() vs. paint()
Other Graphics Performance Tricks?
Common Drawing Problems (and Their Solutions)
The Java Development Environment
Package Tour
The Java Language Package
The Java I/O Package
Input Streams
Output Streams
The Java Utility Package
Managing Your Programming Environment
The CLASSPATH Environment Variable
Creating and Using Packages
Roll Your Own Packages
Using Objects and Classes from Other Packages
Clarifying Object and Class Names
Directory Structure
System
Using the System Class
Standard Output and Error Streams
Using System-Dependent Resources
Miscellaneous System Methods
The Java Compiler
The Java Interpreter
Integrating Native Methods into Java Programs
Step By Step
Step 1: Write the Java Code
Step 2: Compile the Java Code
Step 3: Create the .h File
Step 4: Create a Stubs File
Step 5: Write the C Function
Step 6: Create a Dynamically Loadable Library
Step 7: Run the Program
A Comprehensive Example
How the Java Language Differs from C and C++
C Data Types Not Supported By the Java Language
Operators
Java Command Line Arguments from C and C++
Java Strings are First-Class Objects
Miscellaneous Differences
Troubleshooting
Troubleshooting Compiler Problems
Troubleshooting Interpreter Problems