Home > Store

Special Edition Using Java 2, Standard Edition

Register your product to gain access to bonus material or receive a coupon.

Special Edition Using Java 2, Standard Edition

Premium Website

  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2000
  • Edition: 1st
  • Premium Website
  • ISBN-10: 0-7897-2468-5
  • ISBN-13: 978-0-7897-2468-7

Special Edition Using Java 2 Standard Edition specifically covers only the Standard Edition of version 1.3 of the Java Software Development Kit (SDK). It begins with a series of quick refreshers for Object-oriented programming and Java fundamentals, including applet programming and threads, to ensure that readers are up to speed. The book then moves to intermediate Java features including user interface design with Java Foundation Classes (JFC) and Abstract Windows Toolkit (AWT), data structures and Java utilities, containers and layout managers, and creating images. Later chapters cover advanced topics including Internationalization & creating JAR archive files. Useful appendices offer further Java resources & SDK tool information. Throughout the book, the authors focus on Java 2 Standard Edition SDK version 1.3 changes, including the newest “HotSpot” compiler, which offers increased performance, faster start-up and smaller memory usage, among other improvements.



All the source code for the examples developed in the book in one convenient download - 4,451 kb -- source-windows.zip

All the source code for the examples developed in the book in one convenient download - 4,079 kb -- source-mac.sea

Source Code

This file contains the source code for this title - Windows self-extracting executable #1 - 3652KB -- source1.exe
This file contains the source code for this title - Windows self-extracting executable #2 - 833KB -- source2.exe
This file contains the source code for this title - Mac format - 4079KB -- source-mac.sea

Sample Content

Table of Contents


This Book Is for You. How This Book Is Organized. Conventions Used in This Book.


1. Object-Oriented Programming.

Object-Oriented Programming: A Different Way of Thinking. A Short History of Programming.

Procedural Languages. Structured Development. Object-Oriented Programming.

A Lesson in Objects.

Traditional Program Design. The OOP Way. Extending Objects Through Inheritance.

Objects as Multiple Entities. Modularity and Code Organization. Relating Objects to Java Classes. Building a Hierarchy: Steps in OOP Design.

Decompose the Problem into Entities. Look for Commonality Between Entities. Look for Differences Between Entities. Design a Hierarchy Using Abstraction and Inheritance.

OOP and the UML.

UML in Brief. Class Diagrams. Sequence Diagrams. UML Guidelines.

Is Java a Magic OOP Bullet?

2. HelloWorld: Your First Java Program.

HelloWorld Application.

Create the File. Compile the Code. Run the Program.

Understanding HelloWorld.

Comments. Declaring a Class. The main Method. Writing to the Screen. System.out and System.in.

HelloWorld as an Applet.

Modifying and Compiling the Source Code. Creating an HTML File. Running the Program in AppletViewer. Running HelloWorld in Internet Explorer. Importing Other Classes. Declaring an Applet Class. Applet paint Method. The Brief Life of an Applet.

Keywords. The Java 1.3 API. Troubleshooting.

3. Data Types and Other Tokens.

Java Data Types.

Primitives. Reference Types.

Working with Variables.

Declaring a Variable. Identifiers: The Naming of a Variable.

The boolean Primitive. The Flavors of Integer.

Limits on Integer Values. Declaring Integer Variables. Operations on Integers.


Arithmetic Operators. Assignment Operators. Increment/Decrement Operators.

Character Variables. Floating-Point Variables. Literals: Assigning Values. Integer Literals. Character Literals. Floating-Point Literals. String Literals. Arrays. Non-Token Input Elements.

Whitespace. Comments.


4. Methods and Exceptions.

Declaring a Method.

Access Specifiers. Modifiers. Returning Information. Method Name. Parameters. Exceptions.

Blocks and Statements.

Labeled Statements. Scope. Local Variable Initialization.

Methods and the UML Sequence Diagram. Catching and Throwing Exceptions.

Using try/catch/finally. Throwing an Exception. A Combined Approach. Types of Exceptions. Handling Multiple Exceptions. Creating Your Own Exception Classes. Exceptions Versus Return Values.

Java's Error Classes. Troubleshooting.

5. Using Expressions.

What Is an Expression? How Expressions Are Evaluated.

Operator Associativity. Operator Precedence. Order of Evaluation.

Of Special Interest to C Programmers. Bitwise Operators. Shift Operators.

Left Shift. Signed Right Shift. Unsigned Right Shift.

Type Conversions.

Implicit Conversions. Explicit Conversions Using the Cast Operator. Character Conversions.

Special Operator Support for Strings. Troubleshooting.

6. Control Flow.

Controlling the Flow of Execution. Boolean Operators.

The Relational Operators. The Equality Operators.

Logical Expressions.

Conditional-AND and Conditional-OR Operators. The Logical Negation Operator.

The Conditional Operator. Booleans in Control Flow Statements. Control Flow Functions.

if Statements. if-else Statements.

switch Statements. Iteration Statements.

while Loops. do Loops. for Loops.

Jump Statements.

break Statements. continue Statements. return Statements.


7. Classes.

What Are Classes? Why Use Classes? Classes in Java. Declaring a Class.

Access Specifiers. Modifiers. Class Name. Superclasses-Extending Another Class.

Variables-Defining State.

Access Specifiers. Modifiers. Instance Fields. Class Fields. Declaring a Constant. Implementing an Enumerated Type.

Methods-Defining Behavior.

Constructors. Overriding Methods. Using Methods to Provide Guarded Access. Class Methods.

Creating an Instance of a Class.

The new Operator. Garbage Collection.

Referring to Class Elements. The Object Class.

Object Equality. Copying a Class Instance. Cleaning Up in the finalize() Method.

Casting and Converting Reference Types.

Compile-Time Versus Runtime Type Checking. Using the instanceof Operator.

Inner Classes.

Inner Classes Defined. Reasons to Use Inner Classes. How Inner Classes Work.


Using Packages to Organize Your Code. Packages and Your File System. Importing a Class from Another Package. Importing an Entire Package. Using a Class Without Importing It. Implicit Import of java.lang.

Wrapping the Primitive Types in Classes. Using the Standard Mathematical Functions. Building a UML Class Diagram. Troubleshooting.

8. Using Strings and Text.

Introducing Strings. Using the String Class. Getting Information About a String Object. Comparing Strings. String Extraction. String Manipulation. Concatenating Strings. Converting Objects to Strings. Converting Primitives to Strings. Using the StringBuffer Class.

Creating a StringBuffer Object. Appending to a StringBuffer. Converting a StringBuffer Object to a String. Manipulating a StringBuffer Object.

Using the StringTokenizer Class.

Getting All the Tokens from a File.

Strings and the Compiler. Troubleshooting.

9. Interfaces.

What Are Interfaces?

Doesn't Every Class Already Have an Interface? Multiple Inheritance.

Defining an Interface.

The Declaration. The Body. Marker Interfaces.

Implementing an Interface.

Overriding the Methods. Modifiers. Parameter List. Body. Exceptions. Interface Method Collisions.

Referencing Interfaces.

Accessing Constants. Design to an Interface Rather Than an Implementation.

Choosing Between an Interface and an Abstract Class. Depicting Interfaces in UML. Troubleshooting.

10. Data Structures and Java Utilities.

Collection and Utility Classes. The Collections Framework. Collection Interfaces.

Collection. List. Set and SortedSet. Map and SortedMap.

In the Beginning.

Vector. Stack. Hashtable.

General-Purpose Implementations.

ArrayList. LinkedList. HashMap. TreeMap. WeakHashMap. HashSet. TreeSet.

Sorting a Collection.

The Comparable Interface. The Comparator Interface. Using Collections.sort().

Iterating a Collection.

The Iterator Interface. The ListIterator Interface. Efficient Searching.

Collection Utilities and Wrappers.

Utility Methods and Fields. Singletons. Synchronized Collections. Unmodifiable Collections.

Which Collection Class to Use? Array Utilities.

The Arrays Class.

Configuring an Application Using the Properties Class.

Setting Properties. Querying Properties. Saving and Retrieving Properties.

Working with Dates.

The Date Class.

The BitSet Class. Generating Random Numbers. Monitoring State Changes Using Observer/Observable.

The Observable Class. The Observer Interface.


11. Threads.

What Are Threads? Why Use Threads? How to Make Your Classes Threadable. Extending Thread. Implementing Runnable. The Life Cycle of a Thread. Using Thread Local Variables. Changing Thread Priorities. Thread Synchronization.

Communicating Between Threads.

Changing the Running State of a Thread. Thread Groups. Obtaining the Number of Running Threads. Yielding to Other Threads. Daemon Threads. Using the Timer and TimerTask Classes. Making Your Application Thread-Safe. Troubleshooting.


12. Introduction to Java Foundation Classes.

What Is the JFC?

AWT. Swing. Accessibility. Java 2D. Drag and Drop.

History of the JFC.

AWT 1.0. Internet Foundation Classes. Application Foundation Classes. Java Foundation Classes. Vision of the Future.

JFC Applications.

A Taste of JFC's AWT Applications. A Taste of JFC's Swing Applications.


What Is an Applet? Applets and the World Wide Web. AWT Applets. Swing Applets. Architecture. Applets Versus Applications.


13. Beginning AWT.

What Is the AWT? Graphics

The Fundamentals of Drawing. Drawing Text. Drawing Shapes. Utility Classes and Interfaces. Utility Methods.

Fonts and Colors.

Getting to Know Fonts. Creating Fonts. Measuring Fonts. A Dash of Color. System Colors.


Loading and Drawing Images. Animation. Producing Images. Consuming Images. Filtering Images.


14. Building a GUI: AWT Style.

Introducing the Windowing Toolkit. Building a GUI: Components, Containers, and Layout Managers.

Exploring the System Toolkit. Exploring Peers, Heavyweights, and Lightweights. Exploring Components. Exploring Containers. Exploring Layout Managers.

Building a GUI: Events and Listeners.

Exploring Events. Exploring Listeners.

Customizing the Windowing Toolkit.

Building Your Own Containers. Building Your Own Layout Managers.


15. And Then There Was Swing.

What Is Swing? Comparing Swing to the AWT. Mixing Heavyweight and Lightweight Components. Converting from the AWT to Swing. Troubleshooting.

16. Building a GUI: Swing Style.

A Swinging Toolkit.

Model-View-Controller Architecture. Pluggable Look and Feel.

Building a GUI: Components, Containers, and Layout Managers.

Exploring Components. Exploring Containers. Exploring Layout Managers.

Building a GUI: Events and Listeners. Odds and Ends.

Actions. Borders. Keystrokes and Bindings. Painting. Properties. Threading Issues. Timers.


17. Accessibility.

What Is Accessibility? How Does Accessibility Work? Utilities.

AccessibilityMonitor. AWTMonitor. Ferret. JavaMonitor. Linker. Monkey.

Robots. Troubleshooting.

18. Java 2D.

What Is Java 2D?

Graphics2D. Coordinate Systems. The API.

Rendering 101.

Rendering Hint Attributes. Stroke attributes. Paint Attributes. Transform Attributes. Clipping Path Attributes. Composition Attributes.

Shapes, Text, and Buffered Images.

Shapes. Text. Buffered Images.


The Printing Framework. Job Control and Rendering. Playing with Printables. Playing with Pageables.


19. Drag and Drop.

What Is Drag and Drop? First Comes Data Transfer.

Data Flavors. Transferables. Clipboard Owners. Clipboards.

Then Comes Drag and Drop. Troubleshooting.

20. Java Media Framework.

What Is JMF?

Downloading and Installing JMF. The API. A Layered Architecture. Media Streams. Time Bases and Clocks. Managers.

Playing Media. Processing Media. Capturing Media. Troubleshooting.


21. Streams, Files, and Serialization.

What Are Streams? Working with the Stream Classes. Reading and Writing Data Using Byte Streams.

The InputStream Class. The OutputStream Class. Reading and Writing Byte Arrays. Reading and Writing Files. Stream Buffering. Filtering Streams. Print Streams.

Redirecting Standard Input/Output. Using Readers and Writers.

Using BufferedReader and BufferedWriter. Using the LineNumberReader. Using InputStreamReader and OutputStreamReader. PrintWriter Class.

Working with Files. Creating Files.

Creating Temporary Files.

Reading and Writing Files.

Random File Access. File Security.

Directory Operations.

Deleting Files on Exit.

Object Streams. Troubleshooting.

22. Object Serialization.

What Is Object Serialization?

How Object Serialization Works. Dealing with Objects with Object References.

Object Serialization Example. Reading and Writing Your Own Objects. Customizing Object Serialization.

Using the Transient Keyword.

Using the Externalizable Interface. Troubleshooting.

23. Communications and Networking.

Overview of Network Communications. TCP/IP Architecture.

TCP/IP Protocols. Internet Protocol (IP). Transmission Control Protocol (TCP).

Working with Sockets.

What Is a Socket? Client Sockets. Server Sockets.

Compressing Data When Using Sockets. Sending Objects Across the Network Using Sockets.

Sending Objects Using Sockets

Obtaining Hostname and IP Address Information. User Datagram Protocol (UDP).

UDP Socket Characteristics. Java UDP Classes. A Datagram Example. Multicasting.

World Wide Web Overview. Understanding the Request/Response Scenario. Using the URL Classes.

What Are URLs? Creating a URL Object. Creating a URL Connection. Reading and Writing to a URL Connection.

An Example: Building a World Wide Web Graph. HTTP and SSL. Java Secure Socket Extension Package Overview. Troubleshooting.

24. Using Internationalization.

What Is Internationalization? Java Support for Internationalization. The Locale Class.

Supported Locales.

Packaging Locale-Sensitive Data.

Resource Bundles. ListResourceBundles. PropertyResourceBundle.

Calendar and Time Zone Support.

Calendar Class.

Internationalization Formatting.

Format Class. Date and Time Formatting. Number Formatting. Message Formatting.

Character Set Converters. Readers and Writers. The java.text Package. An Example: InternationalizationTest. Troubleshooting.

25. JAR Files.

Using JAR Files.

Bundling. Compression. Portability. Versioning. Security. Decreased Download Time.

Some Differences Between ZIP and JAR Formats.

When to Use JARs.

Creating and Viewing a JAR.

Listing Archive Contents. Extracting Files from an Archive. Updating a JAR File.

The Manifest File.

Applications Bundled as JAR Files. Package Sealing. Package Versioning. Download Extension.

Reading and Writing JAR Files. Adding a JAR to Your Classpath. JARs and Security.

Private Keys, Public Keys, and Certificates. keytool. jarsigner.

When to Use JARs. Troubleshooting.


26. JDBC 2.0 Fundamentals.

What Is the JDBC? JDBC 2.0 Overview. JDBC Drivers.

Type. Type II. Type III. Type IV.

Setting Up a Database.

Setting Up the Example Database Schema.

Installing and Using a JDBC Driver. JDBC URLs. Connecting to the Database.

Loading the Driver. Making the Connection.

Reading Data Using JDBC.

The Statement Class. The ResultSet Class.

Writing Data Using JDBC. Using Prepared Statements. Using Transactions. Getting MetaData from the Database. Using Stored Procedures Troubleshooting.

27. Advanced JDBC 2.0.

New Features in JDBC 2.0 API.

Using Scrollable ResultSets. Using Updatable ResultSets. Using Batch Updates.

Using the JDBC Optional Package.

RowSets. Connection Pooling. Distributed Transactions. DataSource.

Understanding Object-to-Relational Mapping Frameworks. Troubleshooting.


28. Reflection.

What Is Reflection? Key Classes of the Reflection API.

The Constructor Class. The Method Class. The Field Class.

Security Considerations. Creating a Class Knowing Only the List of Constructors. Inspecting a Class for Its Methods.

Obtaining a List of Methods. Using getDeclaredMethod() to Invoke a Method. Invoking Methods That Accept Primitive Types as Parameters.

Accessing the Declared Fields of a Class. Utility Methods. Implementing an Interface Using a Proxy. Troubleshooting.

29. JavaBeans.

Self-Contained Components. Important Concepts in Component Models.

Component Fields or Properties. Component Methods or Functions. Events and Intercommunication. State Persistence and Storage.

The Basics of Designing a JavaBean.

Specifying the Bean's Properties. Specifying the Events the Bean Generates or Responds To. Properties, Methods, and Event Exposure. Initial Property Values and Bean Customizers.

Creating and Using Properties.

Single-Value Properties. Indexed Properties. Bound Properties. Constrained Properties.

Using Events to Communicate with Other Components.

Multicast Events. Unicast Events. Event Adapters.

Introspection: Creating and Using BeanInfo Classes. Customization: Providing Custom PropertyEditors and GUI Interfaces.

PropertyEditors and the PropertyEditorManager. Customization Editor. Providing Alternative Behavior in Non-GUI Environments.

Bean Packaging. Enterprise JavaBeans.

Partitioning Your Applications. Server Components.



Appendix A. Installing the SDK and Getting Started.

Getting the SDK 1.3SE. Installing the SDK 1.3SE.

Installing the SDK for Windows. Installing the SDK for Solaris. Installing the JDK for Linux.

Testing the Java Compiler and JVM.

The Path Environment Variable. The CLASSPATH Environment Variable.

Appendix B. SDK Tools.

SDK Tools Reference. AppletViewer. java-The Java Interpreter. javac-The Java Compiler. javap-The Java Disassembler. The javadoc Tool (Documentation Generator). jdb-The Java Debugger.

Appendix C. SDK 1.3 Performance Improvements.

General Performance Improvements.

Reduce Memory Footprint Associated with Strings. JAR File Memory Usage Reduction. Performance Enhancements in BigInteger. Swing Class Loading.

Introduction to HotSpot Technology. What Makes HotSpot Better?

On-the-Fly Adaptive Compilation. Method Inlining. Improved and Redesigned Object Layout. Fast and Fully Accurate Garbage Collection. Fast Thread Synchronization.

Java HotSpot Client Virtual Machine.

The Java Application Launcher.

Java HotSpot Server Virtual Machine 2.0. Applet Deployment Improvements.

Applet Caching Control. Fast Loading of Applet Support Classes. JAR Indexing. Automatic Installation of Extensions.

Appendix D. Java Resources.

Web Sites. Newsgroups. Mailing Lists.



Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership