Home > Store

Advanced Javaâ„¢ 2 Platform How to Program

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

Advanced Javaâ„¢ 2 Platform How to Program


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





  • Copyright 2002
  • Dimensions: 7" x 9-1/8"
  • Pages: 1496
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-089560-1
  • ISBN-13: 978-0-13-089560-8

The authoritative DEITEL LIVE-CODE guide to programming with the Java 2 Enterprise (J2SE), Standard (J2SE) and Micro (J2ME) Editions

Java has revolutionized application and enterprise-systems development. Using examples and case studies totaling almost 40,000 lines of code, this exciting companion to Java How to Program, 4/e focuses on J2EE-based, enterprise-systems development, presents advanced J2SE concepts and introduces wireless/small-device programming with J2ME.

Dr. Harvey M. Deitel and Paul J. Deitel are the founders of Deitel & Associates, Inc., the internationally recognized corporate-training and content-creation organization specializing in Java, C++, C, C#, Visual Basic®, Visual C++®, .NET, XML, Python, Perl, Internet, Web and object technologies. The Deitels are also the authors of the world's #1 C++ textbook—C++ How to Program, 3/e-and many other best sellers.

In Advanced Java 2 Platform How to Program, the Deitels and their colleague Sean E. Santry discuss the topics you need to build Java-based enterprise systems, including:

  • J2EE/J2SE/J2ME
  • EJB/JDBC/JTS/JMS/JavaBeans
  • Jini/JavaSpaces/Jiro/JMX
  • Servlets/JSP/WAP/WML
  • Secure Sockets/Digital Signatures/JCE/JAAS
  • Advanced Swing/Drag and Drop/MVC
  • Graphics/Java 2D/Java 3D
  • Application Servers/Design Patterns
  • Peer to Peer/Web Services with SOAP
  • Internationalization/Accessibility/JNI/JCP

Advanced Java 2 Platform How to Program includes extensive pedagogic features:

  • Numerous LIVE-CODE programs with screen captures that show exact outputs
  • Extensive World, Wide Web and Internet resources to encourage further research
  • Tips, recommended practices and cautions—all marked with icons

Advanced Java 2 Platform How to Program is the centerpiece of a family of resources for teaching and learning advanced Java 2 Platform programming, including Web sites (www.deitel.com and www.prenhall.com/deitel) with the book's code examples (also on the enclosed CD) and other information for faculty, students and professionals; an optional interactive CD (Advanced Java 2 Platform Multimedia Cyber Classroom) containing hyperlinks, audio walkthroughs of the code examples, solutions to about half the book's exercises; and e-mail access to the authors at deitel@deitel.com.

For information on worldwide corporate on-site seminars and Web-based training offered by Deitel & Associates, Inc., visit: www.deitel.com

For information on Deitel/Prentice Hall publications including How to Program Series books and e-books, Multimedia Cyber Classrooms, Complete Training Courses (that include Deitel books and Cyber Classrooms) and Web-Based Training Courses see the last few pages of this book.

Sample Content

Table of Contents

1. Introduction.

Introduction. Architecture of the Book. Tours of the Book. Running Example Code. Design Patterns.

2. Advanced Swing Graphical User Interface Components.

Introduction. WebBrowser Using JEditorPane and JToolBar. Swing Actions. JSplitPane and JTabbedPane. Multiple-Document Interfaces. Drag and Drop. Internationalization. Accessibility. Internet and World Wide Web Resources.

3. Model-View-Controller.

Introduction. Model-View-Controller Architecture. Observable Class and Observer Interface. JList. JTable. JTree.

4. Graphics Programming with Java 2D and Java 3D.

Introduction. Coordinates, Graphics Contexts and Graphics Objects. Java 2D API. Java 3D API. A Java 3D Case Study: A 3D Game with Custom Behaviors.

5. Case Study: Java 2D GUI Application with Design Patterns.

Introduction. Application Overview. MyShape Class Hierarchy. Deitel DrawingModel. Deitel Drawing Views. Deitel Drawing Controller Logic. DrawingInternalFrame Component. ZoomDialog, Action and Icon Components. DeitelDrawing Application.

6. JavaBeans Component Model.

Introduction. Using Beans in Forte for Java Community Edition. Preparing a Class to be a JavaBean. Creating a JavaBean: Java Archive Files. JavaBean Properties. Bound Properties. Indexed Properties and Custom Events. Customizing JavaBeans for Builder Tools. Internet and World Wide Web Resources.

7. Security.

Introduction. Ancient Ciphers to Modern Cryptosystems. Secret-Key Cryptography. Public-Key Cryptography. Cryptanalysis. Key Agreement Protocols. Key Management. Java Cryptography Extension (JCE). Digital Signatures. Public-Key Infrastructure, Certificates and Certification Authorities. Java Policy Files. Digital Signatures for Java Code. Authentication. Secure Sockets Layer (SSL). Java Language Security and Secure Coding. Internet and World Wide Web Resources.

8. Java Database Connectivity (JDBC).

Introduction. Relational-Database Model. Relational Database Overview: The books Database. Structured Query Language (SQL). Creating Database books in Cloudscape. Manipulating Databases with JDBC. Case Study: Address-Book Application. Stored Procedures. Batch Processing. Processing Multiple ResultSets or Update Counts. Updatable ResultSets. JDBC 2.0 Optional Package javax.sql. Internet and World Wide Web Resources.

9. Servlets.

Introduction. Servlet Overview and Architecture. Handling HTTP get Requests. Handling HTTP get Requests Containing Data. Handling HTTP post Requests. Redirecting Requests to Other Resources. Session Tracking. Multi-Tier Applications: Using JDBC from a Servlet. HttpUtils Class. Internet and World Wide Web Resources.

10. JavaServer Pages (JSP).

Introduction. JavaServer Pages Overview. A First JavaServer Page Example. Implicit Objects. Scripting. Standard Actions. Directives. Custom Tag Libraries. Internet and World Wide Web Resources.

11. Case Study: Servlet and JSP Bookstore.

Introduction. Bookstore Architecture. Entering the Bookstore. Obtaining the Book List from the Database. Viewing a Book's Details. Adding an Item to the Shopping Cart. Viewing the Shopping Cart. Checking Out. Processing the Order. Deploying the Bookstore Application in J2EE 1.2.1.

12. Java-Based Wireless Applications Development and J2ME.

Introduction. WelcomeServlet Overview. TipTestServlet Overview. Java 2 Micro Edition. Installation Instructions. World Wide Web Resources.

13. Remote Method Invocation.

Introduction. Case Study: Creating a Distributed System with RMI. Defining the Remote Interface. Implementing the Remote Interface. Compiling and Executing the Server and the Client. Case Study: Deitel Messenger with Activatable Server. Internet and World Wide Web Resources.

14. Session EJBs and Distributed Transactions.

Introduction. EJB Overview. Session Beans. EJB Transactions. Internet and World Wide Web Resources.

15. Entity EJBs.

Introduction. Entity EJB Overview. Employee Entity EJB. Employee EJB Home and Remote Interfaces. Employee EJB with Bean-Managed Persistence. Employee EJB with Container-Managed Persistence. Employee EJB Client. Internet and World Wide Web Resources.

16. Messaging with JMS.

Introduction. Installation and Configuration of J2EE 1.3. Point-To-Point Messaging. Publish/Subscribe Messaging. Message-Driven Enterprise JavaBeans.

17. Enterprise Java Case Study: Architectural Overview.

Introduction. Deitel Bookstore. System Architecture. Enterprise JavaBeans. Servlet Controller Logic. XSLT Presentation Logic.

18. Enterprise Java Case Study: Presentation and Controller Logic.

Introduction. XMLServlet Base Class. Shopping Cart Servlets. Product Catalog Servlets. Customer Management Servlets.

19. Enterprise Java Case Study: Business Logic Part 1.

Introduction. EJB Architecture. ShoppingCart Implementation. Product Implementation. Order Implementation. OrderProduct Implementation.

20. Enterprise Java Case Study: Business Logic Part 2.

Introduction. Customer Implementation. Address Implementation. SequenceFactory Implementation. Deitel Bookstore Application Deployment with J2EE.

21. Application Servers.

Introduction. J2EE Specification and Benefits. Commercial Application Servers. Deploying the Deitel Bookstore on BEA WebLogic. Deploying the Deitel Bookstore on IBM WebSphere. Internet and World Wide Web Resources.

22. Jini.

Introduction. Installing Jini. Configuring the Jini Runtime Environment. Starting the Required Services. Running the Jini LookupBrowser. Discovery. Jini Service and Client Implementations. Introduction to High-Level Helper Utilities. Internet and World Wide Web Resources.

23. JavaSpaces.

Introduction. JavaSpaces Service Properties. JavaSpaces Service. Discovering the JavaSpaces Service. JavaSpace Interface. Defining an Entry. Write Operation. Read and Take Operations. Notify Operation. Method snapshot. Updating Entries with Jini Transaction Service. Case Study: Distributed Image Processing. Internet and World Wide Web Resources.

24. Java Management Extensions (JMX) (on CD).

Introduction. Installation. Case Study. Internet and World Wide Web Resources.

25. Jiro (on CD).

Introduction. Installation. Starting Jiro. Dynamic vs. Static Services. Dynamic Services. Static Services. Dynamic Service Deployment. Management Policies. Closing Notes on the Printer Management Solution. Internet and World Wide Web Resources.

26. Common Object Request Broker Architecture (CORBA): Part 1 (on CD).

Introduction. Step-by-Step. First Example: SystemClock. Technical/Architectural Overview. CORBA Basics. Example: AlarmClock. Distributed Exceptions. Case Study: Chat. Comments and Comparisons. Internet and World Wide Web Resources.

27. Common Object Request Broker Architecture (CORBA): Part 2 (on CD).

Introduction. Static Invocation Interface (SII), Dynamic Invocation Interface (DII) and Dynamic Skeleton Interface (DSI). BOAS, POAs and TIEs. CORBAservices. EJBs and CORBAcomponents. CORBA vs. RMI. RMIMessenger Case Study Ported to RMI-IIOP. Future Directions. Internet and World Wide Web Resources.

28. Peer-to-Peer Applications and JXTA.

Introduction. Client/Server and Peer-to-Peer Applications. Centralized vs. Decentralized Network Applications. Peer Discovery and Searching. Case Study: Deitel Instant Messenger. Defining the Service Interface. Defining the Service implementation. Registering the Service. Find Other Peers. Compiling and Running the Example. Improving Deitel Instant Messenger. Deitel Instant Messenger with Multicast Sockets. Introduction to JXTA. Internet and World Wide Web Resources.

29. Introduction to Web Services and SOAP.

Introduction. Simple Object Access Protocol (SOAP). SOAP Weather Service. Internet and World Wide Web Resources.

Appendix A. Creating Markup with XML (on CD).

Introduction. Introduction to XML Markup. Parsers and Well-Formed XML Documents. Characters. CDATA Sections and Processing Instructions. XML Namespaces. Internet and World Wide Web Resources.

Appendix B. Document Type Definition (DTD) (on CD).

Introduction. Parsers, Well-Formed and Valid XML Documents. Document Type Declaration. Element Type Declarations. Attribute Declarations. Attribute Types. Conditional Sections. Whitespace Characters. Internet and World Wide Web Resources.

Appendix C. Document Object Model (DOM) (on CD).

Introduction. DOM with Java. Setup Instructions. DOM Components. Creating Nodes. Traversing the DOM. Internet and World Wide Web Resources.

Appendix D. XSL: Extensible Stylesheet Language Transformations (XSLT) (on CD).

Introduction. Applying XSLTs with Java. Templates. Creating Elements and Attributes. Iteration and Sorting. Conditional Processing. Combining Style Sheets. Variables. Internet and World Wide Web Resources.

Appendix E. Downloading and Installing J2EE 1.2.1 (on CD).

Introduction. Installation. Configuration.

Appendix F. Java Community ProcessSM (JCP) (on CD).

Introduction. Participants. Java Community Process.

Appendix G. Java Native Interface (JNI) (on CD).

Introduction. Getting Started with Java Native Interface. Accessing Java Methods and Objects from Native Code. JNI and Arrays. Handling Exceptions with JNI. Internet and World Wide Web Resources.

Appendix H. Career Opportunities (on CD).

Introduction. Resources for the Job Seeker. Online Opportunities for Employers. Recruiting Services. Career Sites. Internet and World Wide Web Resources.

Appendix I. Unicode (on CD).

Introduction. Unicode Transformation Formats. Characters and Glyphs. Advantages/Disadvantages of Unicode. Unicode Consortium's Web Site. Using Unicode. Character Ranges.



Live in fragments no longer. Only connect.
Edward Morgan Forster

Welcome to Advanced Java 2 Platform How to Program and the exciting world of advanced-programming concepts with the three major Java platforms—Java 2 Enterprise Edition (J2EE), Java 2 Standard Edition (J2SE) and Java 2 Micro Edition (J2ME). Little did we know when we attended the November 1995 Internet/World Wide Web conference in Boston what that session would yield—four editions of Java How To Program (the world's best-selling Java textbook), and now this book about Java software-development technologies for upper-level college courses and professional developers.

Before Java appeared, we were convinced that C++ would replace C as the dominant application-development language and systems-programming language for the next decade. However, the combination of the World Wide Web and Java now increases the prominence of the Internet in information-systems planning and implementation. Organizations want to integrate the Internet "seamlessly" into their information systems. Java is more appropriate than C++ for this purpose—as evidenced by Sun Microsystems' announcement in 2001 that over 96% of enterprise application servers support J2EE.

Advanced Java 2 Platform How to Program is the first book in our Advanced How to Program series. We discuss Java technologies that may be unfamiliar and challenging to the average Java programmer. We structured each chapter discussion to provide the reader with an introduction to leading-edge and complex Java technologies, rather than provide a detailed analysis of every nuance of each topic. In fact, each topic we present could be a 600-800 page book in itself.

We use a different approach with the examples in this book than that of programming examples in our previous books. We provide fewer programs, but these programs are more substantial and illustrate sophisticated coding practices. We integrate many technologies to create a book for developers that enables you to "go beyond" and experiment with the most up-to-date technologies and most widely employed design concepts. What better way to learn than to work with actual technologies and code?

When determining the appropriate topics for this book, we read dozens of journals, reviewed the Sun Microsystems Web site and participated in numerous trade shows. We audited our material against the latest technologies presented at the JavaOne conference—the leading Java-developer conference sponsored by Sun Microsystems—and at other popular Java conferences. We also reviewed books on specialized Java topics. After this extensive research, we created an outline for this book and sent it for professional review by Java experts. We found so many topics we wanted to include that we wound up with over 1800 pages of material (several hundred of those pages appear as PDF documents on the CD that accompanies this book). We apologize if this is inconvenient, but the material and the number of topics are voluminous. We will most likely split the next edition into two volumes.

This book benefited from an unusually large pool of excellent reviewers and the detailed documentation that Sun makes available on their Web site (www.sun.com). We were excited to have a number of reviewers from Sun and many other distinguished industry reviewers. We wanted experienced developers to review our code and discussions, so we could offer "expert advice" from people who actually work with the technologies in industry.

We are pleased to include a discussion of application servers in Chapter 21. The three most popular application server software products are BEA's WebLogic, IBM's Web-Sphere and Sun/Netscape's iPlanet. Originally, we had planned to include all three on the book's accompanying CD, but we have included only WebLogic and WebSphere. iPlanet was about to publish a new version as this book went to publication. By mutual agreement between iPlanet and Deitel & Associates, Inc., we decided not to include this software, but iPlanet provides a link to a site specific to this book—www.iplanet.com/ias_deitel—where readers can download the latest iPlanet software. We also include a discussion of how to deploy our case study on the iPlanet server. You can find this discussion on our Web site—www.deitel.com.

We moved four chapters from Java How to Program, Third Edition—RMI, Servlets, JavaBeans and JDBC—to Advanced Java 2 Platform How to Program. Prentice Hall has published a paperback supplement (ISBN: 0-13-074367-4) containing these four chapters for readers who have purchased Java How to Program, Fourth Edition.

The world of Java is growing so rapidly that Advanced Java 2 Platform How to Program and its companion text, Java How to Program, Fourth Edition, total 3400 pages! The books are so large that we had to put several chapters from each on the accompanying CDs. This creates tremendous challenges and opportunities for us as authors, for our publisher—Prentice Hall, for instructors, for students and for professionals. We hope you enjoy the results of these challenges as much as we have enjoyed the process of tackling them.

Features of Advanced Java 2 Platform How to Program

This book contains many features including:

  • Full-Color Presentation. This book is in full color to enable readers to see sample outputs as they would appear on a color monitor. Also, we now syntax color all the Java code, as do many of today's Java integrated development environments and code editors. Our syntax-coloring conventions are as follows:
    - comments appear in green
    - keywords appear in dark blue
    - constants and literal values appear in light blue
    - JSP delimiters appear in red
    - all other code appears in black
  • "Code Washing." This is our own term for the process we use to format the programs in the book with a carefully commented, open layout. The code is in full color and grouped into small, well-documented pieces. This greatly improves code readability—an especially important goal for us given that this book contains almost 40,000 lines of code.
  • Advanced Graphical User Interface (GUI) Design. Starting with Chapter 2, we use advanced Java Swing features to create real-world Java components, including a Web-browser application with a multiple-document interface. In Chapter 3, we introduce the Model-View-Controller (MVC) architecture and its implementation in the Swing API. In Chapters 4 and 5, we create 2D graphics and 3D worlds. The Java 2D Drawing Application with Design Patterns Case Study in Chapter 5 presents a complex drawing program with which the user can create shapes in various colors and gradients. We are also pleased to add Java 3D coverage. One of the book's adopters said these chapters were ideal for a course in advanced GUI programming. (We wanted to include multimedia programming with the Java Media Framework, but instead we decided to include this material in the companion book, Java How to Program, Fourth Edition.)
  • Enterprise Java and Our Enterprise Java Case Study. Developers use Java for building "heavy-duty" enterprise applications. Chapters 7-11, 14-16 and 21 explore the necessary components for implementing enterprise solutions-including security, database manipulation, servlets, JavaServer Pages, distributed transactions, message-oriented middleware and application servers. In Chapter 7, Security, we discuss secure communications and secure programming. Chapters 17-20 showcase an Enterprise Java Case Study that integrates many technologies, such as Enterprise JavaBeans, servlets, RM-IIOP, XML, XSLT, XHTML, (and for wireless application development) WML and cHTML—into an online-bookstore application. The Deitel Bookstore demonstrates how to use the MVC architecture introduced in Chapter 3 to build enterprise applications. This bookstore uses technologies to provide support for almost any type of client, including cell phones, mobile devices and Web browsers. In this world of networks and wireless networks, business information must be delivered securely and reliably to the intended recipients.
  • Distributed Systems. Enterprise applications are usually so complex that they run more efficiently when program components are distributed among different machines in organizations' networks. This book introduces several technologies for building distributed systems—Remote Method Invocation (RMI), Jini, JavaSpaces, Java Management Extensions (JMX), Jiro and Common Object Request Broker Architecture (CORBA). CORBA, controlled by the Object Management Group (OMG), is a mature distributed computing technology for integrating distributed components written in many disparate languages. Java was originally intended for networks of programmable devices—Jini assumes that technology role now. JMX and Jiro are technologies specifically for network management (LANs, WANs, intranets, the Internet, extranets, etc.).
  • Java 2 Micro Edition (J2ME) and Wireless Applications. It is estimated that by 2003, more people worldwide will access the Internet through wireless devices than through desktop computers. The Java platform for wireless devices with limited capabilities such as cell phones and personal digital assistants is Java 2 Micro Edition (J2ME). Chapter 12, Wireless Java-Based Applications Development and J2ME, contains a case study that sends content from a centralized data store to several wireless clients, including a J2ME client.
  • Web Services. Web services are applications that expose public interfaces usable by other applications over the Web. The area of Web services builds on existing protocols, such as HTTP, and communicate with XML-based messages. Directory services enable clients to perform lookups to discover available Web services. The Simple Object Access Protocol (SOAP) uses XML to provide communication in many Web services. Many of the technologies in this book can be used to build Web services.
  • Employing Design Patterns. The book's largest case studies—such as the Java 2D drawing program in Chapter 5, the three-tier servlet and JavaServer Pages case study in Chapter 11, the three-tier wireless application in Chapter 12 and the Deitel Bookstore Enterprise Case Study in Chapters 17-20—each contain thousands of lines of code. Larger systems, such as automated teller machines or air-traffic control systems, can contain hundreds of thousands, or even millions, of lines of code. Effective design is crucial to the proper construction of such complex systems. Over the past decade, the software engineering industry has made significant progress in the field of design patterns—proven architectures for constructing flexible and maintainable object-oriented software. Using design patterns can substantially reduce the complexity of the design process. We used many design patterns when building the software in this book. Chapter 1 introduces design patterns, discusses why they are useful and lists those design patterns we use throughout this book.
  • XML. XML (Extensible Markup Language) use is exploding in the software-development industry and we use it pervasively throughout the text. As a platform-independent syntax for creating markup languages, XML's data portability integrates well with Java's portable applications and services. If you do not know XML, Appendices A-D of this book provide an introduction to XML. Appendices A and B introduce XML basics and DTDs, which define standard XML document structures. Appendix C introduces the Document Object Model (DOM) API for manipulating XML documents. Appendix D covers XSLT (Extensible Stylesheet Language Transformations—an XML vocabulary for transforming XML documents into other text-based documents.
  • Peer-to-Peer Applications, Peer-to-peer (P2P) applications—such as instant messaging and document-sharing programs—have become extremely popular. Chapter 28, Peer-to-Peer Applications and JXTA, introduces this architecture, in which each node performs both client and server duties. JXTA (short for the term "Juxtapose"), defines protocols for implementing peer-to-peer applications. This chapter includes two P2P application case studies—one written with Jini and RMI and the other written in multicast sockets and RMI. Both implement a P2P instant messaging application. We wanted a capstone example for Jini and decided this chapter should have it. The first case study is somewhat centralized—and therefore not a "true" P2P application (some developers think that Jini has too much overhead for a peer-to-peer application). We developed the second to demonstrate a lighter-weight, decentralized implementation.
  • Appendix H, Career Opportunities. This appendix introduces career services on the Internet. We explore online career services from both the employer's and employee's perspectives. We suggest Web sites at which you can submit applications, search for jobs and review applicants (if you are interested in hiring someone). We also review services that build recruiting pages directly into e-businesses. One of our reviewers told us that he had just gone through a job search largely using the Internet and this chapter would have expanded his search dramatically.
  • Appendix I, Unicode. This appendix overviews the Unicode Standard. As computer systems evolved worldwide, computer vendors developed numeric representations of character sets and special symbols for the local languages spoken in different countries. In some cases, different representations were developed for the same languages. Such disparate character sets made communication between computer systems difficult. Java supports the Unicode Standard (maintained by a non-profit organization called the Unicode Consortium), which defines a single character set with unique numeric values for characters and special symbols in most spoken languages. This appendix discusses the Unicode Standard, overviews the Unicode Consortium Web site (www.unicode.org) and shows a Java example that displays "Welcome" in many different languages.
  • Bibliography and Resources. Chapters in this book contain bibliographies when appropriate and URLs that offer additional information about the technologies. We did this so those readers who would like to study a topic further could begin with the resources we found helpful when developing this book.

Some Notes to Instructors

A World of Object Orientation
When we wrote the first edition of Java How to Program, universities were still emphasizing procedural programming in languages like Pascal and C. The leading-edge courses were using object-oriented C++, but these courses were generally mixing a substantial amount of procedural programming with object-oriented programming-something that C++ lets you do, but Java does not. By the third edition of Java How to Program, many universities were switching from C++ to Java in their introductory curricula, and instructors were emphasizing a pure object-oriented programming approach. In parallel with this activity, the software engineering community was standardizing its approach to modeling object-oriented systems with the UML, and the design-patterns movement was taking shape. This book takes a 100% object-oriented approach and emphasizes Java design patterns and adherence to Java idiom.

The prerequisite for this book is Java How to Program, Fourth Edition (or equivalent Java knowledge), which provides a solid foundation in Java programming. Java How to Program, Fourth Edition includes the following chapters and appendices, for a more detailed Table of Contents, visit www.deitel.com: Introduction to Computers, the Internet and the Web; Introduction to Java Applications; Introduction to Java Applets; Control Structures: Part 1; Control Structures: Part 2; Methods; Arrays; Object-Based Programming; Object-Oriented Programming; Strings and Characters; Graphics and Java 2D; Graphical User Interface Components: Part 1; Graphical User Interface Components: Part 2; Exception Handling; Multithreading; Files and Streams; Networking; Multimedia: Images, Animation, Audio and Video; Data Structures; Java Utilities Package and Bit Manipulation; Collections; Java Media Framework and Java Sound; Java Demos; Java Resources; Op erator Precedence Chart; ASCII Character Set; Number Systems; Creating HTML Documentation with javadoc; Elevator Events and Listener Interfaces; Elevator Model; Elevator View; Career Opportunities; Unicode; Bibliography.

Students Like Java
Students are highly motivated by the fact that they are learning a leading-edge language (Java) and a leading-edge programming paradigm (object-oriented programming) for building entire systems. Java immediately gives them an advantage when they head into a world in which the Internet and the World Wide Web have a massive prominence and corporations need enterprise systems programmers. Students quickly discover that they can do great things with Java, so they are willing to put in the extra effort. Java helps programmers unleash their creativity. We see this in the Java and advanced Java courses Deitel & Associates, Inc. teaches.

Focus of the Book
Our goal was clear—produce an advanced Java textbook for higher-level university courses in computer programming for students with intermediate-level Java programming experience, and offer the depth and the rigorous treatment of theory and practice demanded by professionals. To meet these goals, we produced a book that challenges Java programmers. We present clear examples of advanced topics and often overlooked topics. We adhere to Java idiom and follow sophisticated coding style and practices (i.e., not just the code formatting, but the idiomatic use of Java API's, constructs and technologies). This book presents substantial Java applications that readers can use to start working with these technologies immediately.

Evolution of Advanced Java 2 Platform How to Program
Advanced Java 2 Platform How to Program was finished fresh on the heels of Java How to Program, Fourth Edition. Hundreds of thousands of university students and professionals worldwide have learned Java from our texts. Upon publication in September 2001, Advanced Java 2 Platform How to Program will be used in universities, corporations and government organizations worldwide. Deitel & Associates, Inc. taught Java courses internationally to thousands of students as we were writing the various editions of Java How to Program and Advanced Java 2 Platform How to Program. We carefully monitored the effectiveness of material and tuned the books accordingly.

Conceptualization of Java
We believe in Java. Its conceptualization by Sun Microsystems, the creator of Java, was brilliant. Sun based the new language on C and C++, two of the world's most widely used implementation languages. This immediately gave Java a huge pool of highly skilled programmers who were implementing most of the world's new operating systems, communications systems, database systems, personal-computer applications and systems software. Sun removed the more complex and error-prone C/C++ features (such as explicit pointers, operator overloading and multiple inheritance, among others). They kept the language concise by removing special-purpose features used by only small segments of the programming community. They made the language truly portable for implementing Internet-based and Web-based applications, and they included features developers need such as strings, graphics, GUI components, exception handling, multithreading, multimedia (audio, images, animation and video), prepackaged data struc tures, file processing, database processing, Internet and Web-based client/server networking, distributed computing and enterprise computing. Then they made the language available at no charge to millions of potential programmers worldwide.

2.5 Million Java Developers
Java was promoted in 1995 as a means of adding "dynamic content" to Web pages. Instead of Web pages with only text and static graphics, Web pages could now "come alive" with audios, videos, animations, interactivity—and soon, 3D imaging. But we saw much more in Java than this. Java's features are precisely what businesses and organizations need to meet today's information-processing requirements. So we immediately viewed Java as having the potential to become one of the world's key general-purpose programming languages. In fact, Java has revolutionized software development with multimedia-intensive, platform-independent, object-oriented code for conventional, Internet-, Intranet- and Extranet-based applications and applets. Java now has 2.5 million developers worldwide—a stunning accomplishment when considering that it has been available publicly for only six years. No other programming language has ever acquired such a large developer base so quickly.

Teaching Approach

Advanced Java 2 Platform How to Program, First Edition contains a rich collection of examples, exercises and projects drawn from many fields to provide readers with a chance to solve interesting real-world problems. The book concentrates on the principles of good software engineering and stresses program clarity, especially important when creating substantial programs like those covered in this book. We avoid arcane terminology and syntax specifications in favor of teaching by example. Our code examples have been tested on popular Java platforms. We are educators who teach edge-of-the-practice topics in industry classrooms worldwide. The text emphasizes good pedagogy.

Learning Java via the live-code Approach
The book is loaded with live-code examples. This is how we teach and write about programming, and is the focus of each of our multimedia Cyber Classrooms and Web-based training courses. We present each new concept in the context of a complete, working Java program, immediately followed by screen captures that show the program's output. We call this style of teaching and writing our live-code approach. We use the language to teach the language. Reading these programs (almost 40,000 lines of code) is much like entering and running them on a computer.

Java Programming from Chapter Two
Advanced Java 2 Platform How to Program, "jumps right in" with substantial programs right from Chapter 2. This is the beginning of an aggressive pace that challenges readers with graphical, multithreaded, database-intensive, network-based programming. Throughout the book, readers learn by implementing impressive projects.

World Wide Web Access
All the code for Advanced Java 2 Platform How to Program is on the CD that accompanies this book. The code also is available at the following Web sites: www.deitel.com and www.prenhall.com/deitel

Each chapter begins with Objectives that inform the reader what to expect and provides an opportunity, after reading the chapter, to determine if the reader has met these objectives. It is a confidence builder and a source of positive reinforcement.

The learning objectives are followed by quotations. Some are humorous, some are philosophical and some offer interesting insights. Our readers enjoy relating the quotations to the chapter material. The quotations are worth a "second look" after you read each chapter.

The chapter outline helps the reader approach the material in top-down fashion. This, too, helps students anticipate what is to come and set a comfortable and effective learning pace.

Almost 40,000 Lines of Code in 126 Example Programs (with Program Outputs)
We present Java features in the context of complete, working Java programs. The programs in this book are substantial, with hundreds to thousands of lines of code (e.g., 10,000 lines of code for the bookstore case study example). Students should use the program code from the CD that accompanies the book and run each program while studying that program in the text.

841 Illustrations/Figures
Many of the figures are code examples, but this book still offers many charts, line drawings and program outputs. For example, Chapter 4 and 5, Graphics Programming with Java 2D and Java 3D, provides stunning graphics, and the architectural overview of the Enterprise Java case study in Chapter 17 is impressive.

235 Programming Tips
We have included programming tips to help students focus on important aspects of program development. We highlight numerous tips in the form of Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Performance Tips, Portability Tips, Software Engineering Observations and Look-and-Feel Observations. These tips and practices represent the best we have gleaned from decades of programming and teaching experience. One of our students—a mathematics major—told us that she feels this approach is like the highlighting of axioms, theorems and corollaries in mathematics books; it provides a basis on which to build good software.

  • Good Programming Practices
    We highlight Good Programming Practices techniques for writing programs that are clearer, more understandable, more debuggable and more maintainable.
  • Common Programming Errors
    Focusing on these Common Programming Errors helps readers avoid making the same errors.
  • Testing and Debugging Tips
    When we first designed this "tip type, " we thought we would use it strictly to tell people how to test and debug Java programs. In fact, many of the tips describe aspects of Java that reduce the likelihood of "bugs" and thus simplify the testing and debugging process.
  • Performance Tips
    We have included 13 Performance Tips that highlight opportunities for improving program performance—making programs run faster or minimizing the amount of memory that they occupy.
  • Portability Tips
    One of Java's "claims to fame" is "universal" portability, so some programmers assume that if they implement an application in Java, the application will automatically be ` perfectly" portable across all Java platforms. Unfortunately, this is not always the case. We include Portability Tips to help readers write portable code and to provide insights on how Java achieves its high degree of portability.
  • Software Engineering Observations
    The object-oriented programming paradigm requires a complete rethinking about the way we build software systems. Java is an effective language for performing good software engineering. The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems.
  • Look-and-Feel Observations
    We provide Look-and-Feel Observations to highlight graphical user interface conventions. These observations help readers design their own graphical user interfaces in conformance with industry norms.

Summary (949 Summary bullets)
Each chapter ends with additional pedagogical devices. We present a thorough, bullet-list-style summary of the chapter. On average, there are 26 summary bullets per chapter. This helps the readers review and reinforce key concepts.

Terminology (1904 Terms)
We include in a Terminology section an alphabetized list of the important terms defined in the chapter—again, further reinforcement. On average, there are 51 terms per chapter.

394 Self-Review Exercises and Answers (Count Includes Separate Parts)
Self-review exercises and answers are included for self-study. These reinforce the knowledge the reader gained from the chapter.

189 Exercises (Count Includes Separate Parts)
Each chapter concludes with a set of exercises. The exercises cover many areas. This enables instructors to tailor their courses to the unique needs of their audiences and to vary course assignments each semester. Instructors can use these exercises to form homework assignments, quizzes and examinations. The solutions for most of the exercises are included on the Instructor's Manual CD that is available only to instructors through their Prentice-Hall representatives. NOTE: Please do not write to us requesting the instructor's manual. Distribution of this publication is strictly limited to college professors teaching from the book. Instructors may obtain the Instructor's manual only from their Prentice Hall representatives. We regret that we cannot provide the solutions to professionals. Solutions to approximately half of the exercises are included on the Advanced Java 2 Platform Multimedia Cyber Classroom CD, which also is part of The Complete Advance d Java 2 Platform Training Course. For ordering instructions, please see the last few pages of this book or visit www.deitel.com.

Approximately 3,080 Index Entries (with approximately 4648 Page References)
This book includes an extensive index. This helps the reader find any term or concept by keyword. The index is useful to developers who use the book as a reference. The terms in the Terminology sections generally appear in the index (along with many more index items from each chapter).

"Double Indexing" of Java live-code Examples and Exercises
Advanced Java 2 Platform How to Program has 126 live-code examples and 189 exercises (including parts). Many exercises are challenging problems or projects that require substantial effort. We have "double indexed" the live-code examples. For every Java source-code program in the book, we took the file name with the .java extension, such as WebBrowser.java and indexed it both alphabetically (in this case under "W") and as a subindex item under "Examples." This makes it easier to find examples using particular features.

Software Included with Advanced Java 2 Platform How to Program

There are a number of for-sale Java products available. However, you do not need them to get started with Java. We wrote Advanced Java 2 Platform How to Program using the Java 2 Software Development Kit (J2SDK) Standard Edition Version 1.3.1 for Windows and Linux (Intel x86) and other software programs that we include on the CD that accompanies this book. For your convenience, Sun's J2SDK also can be downloaded from the Sun Microsystems Java Web site java.sun.com/js2e. We include some of the most popular server software so you can set up and run live systems. This software includes BEA WebLogic Server, Version 6.0 (Windows/Linux) with Service Pack 2, 30-Day Trial, Enterprise Edition, 6.0, Testdrive; IBM© WebSphere® Application Server, Advanced Single Server Edition, Version 4.0 for Windows NT® and Windows® 2000 Evaluation Copy, and Apache Tomcat 3.2.3 from the Apache Software Foundation. We also include Informix Software's Cloudscape 3.6.4 database software. With Sun's cooperation, we also were able to include on the CD a powerful Java integrated development environment (IDE)—Sun Microsystems Forte for Java Community Edition. Forte is a professional IDE written in Java that includes a graphical user interface designer, code editor, compiler, visual debugger and more. J2SDK 1.3.1 must be installed before installing Forte. If you have any questions about using this software, please read the introductory Forte documentation on the CD. We will provide additional information on our Web site www.deitel.com

The CD also contains the book's examples and a Web page with links to the Deitel & Associates, Inc. Web site (www.deitel.com), the Prentice Hall Web site (www.prenhall.com/deitel) and the many Web sites listed at the end of each chapter. If you have access to the Internet, this Web page can be loaded into your Web browser to give you quick access to all the resources. Finally, because we wrote much more than we originally intended, a number of chapters and appendices have been off-loaded to the CD.

Ancillary Package for Advanced Java 2 Platform How to Program

Advanced Java 2 Platform How to Program has extensive ancillary materials for instructors teaching from the book. The Instructor's Manual CD contains solutions to the vast majority of the end-of-chapter exercises. We also provide PowerPoint® slides containing all the code and figures in the text. You are free to customize these slides to meet your own classroom needs. Prentice Hall provides a Companion Web Site (www.prenhall.com/deitel) that includes resources for instructors and students. For instructors, the Web site has a Syllabus Manager for course planning, links to the PowerPoint slides and reference materials from the appendices of the book (such as the character sets and Web resources). For students, the Web site provides chapter objectives, true/false exercises with instant feedback, chapter highlights and reference materials. NOTE: Please do not write to us requesting the instructor's manual. Distribution of this publication is strictly limited to college professors teaching from the book. Instructors may obtain the solutions manual only from their regular Prentice Hall representatives. We regret that we cannot provide the solutions to professionals.


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020