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
The "run:" Protocol Handler
The "text/plain:" Content Handler
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?
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
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
The Anatomy of an Applet
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 Application
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
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
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