Home > Store

Core Java 2, Volume II--Advanced Features, 4th Edition

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

Core Java 2, Volume II--Advanced Features, 4th Edition

Book

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

About

Features

  • NEW - Thoroughly updated for Java 2, with thousands of lines of new code.
  • NEW - Based on Sun's final Java 2 release.
  • NEW - Completely new chapters on Collections, Advanced Swing, and Advanced Graphics.
  • NEW - Brand-new coverage of multithreading, networking, and JDBC 2.0.
  • NEW - Brand-new coverage of CORBA and JavaBeans.
  • NEW - Brand-new coverage of security and native methods.
  • CD-ROM contains all source code from the book.

Description

  • Copyright 2000
  • Edition: 4th
  • Book
  • ISBN-10: 0-13-081934-4
  • ISBN-13: 978-0-13-081934-5


8193D-2

  • More advanced topics and real-world code for experienced developers
  • New chapters on collections, swing, and the Java 2D™ API
  • Thoroughly revised coverage of multithreading, networking, and JDBC™
  • Remote objects, and more
  • Fully updated and tested code for the Java 2 platform

More hardcore Java technology for experienced programmers!

Over 250,000 programmers have relied on Core Java to master the fundamentals of Java technology. Now, this expanded second volume provides developers the comprehensive guide they need to solve real-world problems and is an indispensable companion to Core Java 2, Vol. I-Fundamentals, (0-13-766957-7). Completely revised and updated, the new edition features coverage of the advanced features and libraries of the Java 2 Platform and even more of the source code examples that have won universal praise for Core Java.

This volume includes new sections on multithreading in Swing programs, JDBC2, CORBA, the drag-and-drop mechanism, and the Java 2 security model, as well as three completely new chapters. A new advanced Swing chapter covers the complex GUI components for trees and tables as well as sliders, progress meters, tool bars, and tool tips. Also, a new chapter, "Collections," explores the design of the Java collections framework and shows how to use the fundamental data structures that the standard Java library supplies. In addition, the new "Advanced AWT" chapter shows how to use the Java 2D™ API to produce high-quality drawings.

Inside Core Java 2, Volume II-Advanced Features:

  • Multithreading
  • Collections
  • Networking
  • Database Connectivity: JDBC
  • Remote Objects
  • Advanced Swing
  • Advanced AWT
  • JavaBeans™
  • Security
  • Internationalization
  • Native Methods

About the CD-ROM

CD-ROM includes complete source code examples from the book, the Java 2 SDK, Standard Edition, v 1.2.2, and trial versions of useful Java-based tools.

Downloads

Downloads

To facilitate your work with Core Java 2, we are making available for download the code examples for the books below:

Sample Content

Downloadable Sample Chapter

Click here for a sample chapter for this book: 0130819344.pdf

Table of Contents



1. Multithreading.

What Are Threads? Using Threads to Give Other Tasks a Chance. Running and Starting Threads. Running Multiple Threads. Thread Properties. Thread States. Moving Out of a Blocked State. Dead Threads. Interrupting Threads. Thread Priorities. Selfish Threads. Thread Groups. Synchronization. Thread Communication Without Synchronization. Synchronizing Access to Shared Resources. Object Locks. The Wait and Notify Methods. Deadlocks. Why the Stop and Suspend Methods Are Deprecated. Animation. The Runnable Interface. Loading and Displaying Frames. Using a Thread to Control the Animation. Timers. Daemon Threads. Threads and Swing. Using Pipes for Communication Between Threads.



2. Collections.

Collection Interfaces. Separating Collection Interfaces and Implementation. Collection and Iterator Interfaces in the Java Library. Concrete Collections. Linked Lists. Array Lists. Hash Sets. Tree Sets. Maps. The Collections Framework. Views and Wrappers. Bulk Operations. Interfacing with Legacy APIs. Algorithms. Sorting and Shuffling. Binary Search. Simple Algorithms. Writing Your Own Algorithms. Legacy Collections. The Hashtable Class. Enumerations. Property Sets. Bit Sets.



3. Networking.

Connecting to a Server. Implementing Servers. Serving Multiple Clients. Sending E-mail. URL Connections. Retrieving Information from a Remote Site. Posting Form Data. CGI Scripts and Servlets. Sending Data to a Web Server. Harvesting Information from the Web. Applet Security. Proxy Servers. Testing the WeatherReport Applet.



4. Database Connectivity: JDBC.

The Design of JDBC. Typical Uses of JDBC. The Structured Query Language. Installing JDBC. Basic JDBC Programming Concepts. Database URLs. Making the Connection. Executing Action Commands. Querying with JDBC. Advanced SQL Types (JDBC 2). Populating a Database. Batch Updates (JDBC 2). Executing Queries. Metadata. Scrollable and Updatable Result Sets. Scrollable Result Sets (JDBC 2). Updatable Result Sets (JDBC 2).



5. Remote Objects.

Introduction to Remote Objects: The Roles of Client and Server. Remote Method Invocations. Stubs and Parameter Marshalling. Dynamic Class Loading. Setting Up Remote Method Invocation. Interfaces and Implementations. Locating Server Objects. The Client Side. Preparing for Deployment. Deploying the Program. Parameter Passing in Remote Methods. Passing Nonremote Objects. Passing Remote Objects. Using Remote Objects in Sets. Cloning Remote Objects. Inappropriate Remote Parameters. Using RMI with Applets. Java IDL and CORBA. The Interface Definition Language. A CORBA example. Implementing CORBA Servers.



6. Advanced Swing.

Trees. Tables. A Simple Table. Table Models. Cell Rendering and Editing. Working with Rows and Columns. Styled Text Components. Sliders and Progress Meters. Sliders. Progress Bars. Progress Monitors. Monitoring the Progress of Input Streams. Tool Bars and Tool Tips. Tool Tips. Component Organizers. Split Panes. Tabbed Panes. Desktop Panes and Internal Frames.



7. Advanced AWT.

The Rendering Pipeline. Shapes. Areas. Strokes. Paint. Coordinate Transformations. Clipping. Transparency and Composition. Rendering Hints. Image Manipulation. Accessing Image Data. Filtering Images. Printing. Printing Single Sheets. Printing Multiple Pages. Print Preview. The Clipboard. Classes and Interfaces for Data Transfer. Transferring Text. Building a Transferable. Building an Image Transferable. Using the ImageSelection Class. Transferring Java Objects via the System Clipboard. Drag and Drop. Drop Targets. Drag Sources.



8. JavaBeans?

Why Beans? The Bean-Writing Process. The BDK and the BeanBox. Using the BeanBox. Building an Image Viewer Application via Beans. Naming Patterns for Bean Properties and Events. Bean Property Types. Simple Properties. Indexed Properties. Bound Properties. Constrained Properties. Adding Custom Bean Events. Property Editors. Writing a Property Editor. Going beyond Naming Patterns-Building a BeanInfo Class. FeatureDescriptor Objects. Customizers. Writing a Customizer Class. The Bean Context. Advanced Uses of Introspection. Finding Sibling Beans. Using Bean Context Services.



9. Security.

Class Loaders. Writing Your Own Class Loader. Bytecode Verification. Security Managers and Permissions. Java 2 Platform Security. Security Policy Files. Custom Permissions. Implementing a Permissions Class. A Custom Security Manager. The java.security Package. Message Digests. Digital Signatures. Authentication. The X.509 Certificate Format. Generating Certificates. Signing Certificates. Code Signing. Signing JAR Files. Deployment Tips. Software Developer Certificates.



10. Internationalization.

Locales. Numbers and Currencies. Date and Time. Text. Collation (Ordering). Text Boundaries. Message Formatting. Choice Formats. Character Set Conversion. International Issues and Source Files. Resource Bundles. Locating Resources. Placing Resources into Bundles. Graphical User Interface Localization. Localizing an Applet.



11. Native Methods.

Calling a C Function from the Java Programming Language. Working with the printf Function. Numeric Parameters and Return Values. Using printf for Formatting Numbers. String Parameters. Calling sprintf in a Native Method. Accessing Object Fields. Accessing Static Fields. Signatures. Calling Java Methods. Nonstatic Methods. Static Methods. Constructors. Alternative Method Invocations. Arrays. Error Handling. The Invocation API. A Complete Example: Accessing the Windows Registry. An Overview of the Windows Registry. A Java Platform Interface for Accessing the Registry. Implementing the Registry Access Functions as Native Methods.



Index.

Preface

To the reader

The book you have in your hands is the second volume of the fourth edition of Core Java. The first edition appeared in early 1996, the second in late 1996, and the third in 1997/1998. The first two editions appeared in a single volume, but the second edition was already 150 pages longer than the first, which was itself not a thin book. When we sat down to work on the third edition, it became clear that a one-volume treatment of all the features of the JavaTM platform that a serious programmer needs to know was no longer possible. Hence, we decided to break up the third edition into two volumes. In the fourth edition, we again organized the material into two volumes. However, we rearranged the materials, moving streams into volume 1 and collections into Volume 2.

The first volume covers the essential features of the language; this volume covers the advanced topics that a programmer will need to know for professional software development. Thus, as with the first volume and the previous editions of this book, we still are targeting programmers who want to put Java technology to work on real projects.

Please note: If you are an experienced developer who is comfortable with the new event model and advanced language features such as inner classes, you need not have read the first volume in order to benefit from this volume. (While we do refer to sections of the previous volume when appropriate and, of course, hope you will buy or have bought Volume 1, you can find the needed background material in any comprehensive introductory book about the Java platform.)

Finally, when any book is being written, errors and inaccuracies are inevitable. We would very much like to hear about them. Of course, we would prefer to hear about them only once. For this reason, we have put up a web site at http://www.horstmann.com/corejava.html with an FAQ, bug fixes, and workarounds. Strategically placed at the end of the bug report web page (to encourage you to read the previous reports) is a form that you can use to report bugs or problems and to send suggestions for improvements to future editions.

About This Book

The chapters in this book are, for the most part, independent of each other. You should be able to delve into whatever topic interests you the most and read the chapters in any order.

Chapter 1 covers multithreading, which enables you to program tasks to be done in parallel. (A thread is a flow of control within a program.) We show you how to set up threads and how to make sure none of them get stuck. We put this knowledge to practical use by example, showing you the techniques needed to build timers and animations.

The topic of Chapter 2 is the collections framework of the Java 2 platform. Whenever you want to collect multiple objects and retrieve them later, you will want to use a collection that is best suited for your circumstances, instead of just tossing the elements into a Vector. This chapter shows you how to take advantage of the standard collections that are prebuilt for your use.

Chapter 3 covers one of the most exciting APIs in the Java platform: the networking API. Java makes it phenomenally easy to do complex network programming. Not only do we cover this API in depth, we also discuss the important consequences of the applet security model for network programming.

Chapter 4 covers JDBCTM, the Java database connectivity API. We show you how to write useful programs to handle realistic database chores, using a core subset of the JDBC API. Please note that this is not a complete treatment of everything you can do with the rich JDBC API. (A complete treatment of the JDBC API would require a book almost as long as this one.)

Chapter 5 covers remote objects and Remote Method Invocation (RMI). This API lets you work with Java objects that are distributed over multiple machines. We also show you where the rallying cry of "objects everywhere" can realistically be used.

Chapter 6 contains all the Swing material that didn't make it into volume 1, especially the important but complex tree and table components. We show the basic uses of editor panes and the Java technology implementation of a "multiple document" interface. Again, we focus on the most useful constructs that you are likely to encounter in practical programming, since an encyclopedic coverage of the entire Swing library would fill several volumes and would only be of interest to dedicated taxonomists.

Chapter 7 covers the Java 2D API that you can use to create realistic drawings. The chapter also covers some advanced features of the Abstract Windowing Toolkit (AWT) that seemed too specialized for coverage in Volume 1 but are, nonetheless, techniques that should be part of every programmer's toolkit. These features include printing and the APIs for cut-and-paste and drag-and-drop. We actually take the cut-and-paste API one step further than Sun Microsystems itself did: We show you how to cut and paste serializable Java objects between different programs in the Java programming language via the system clipboard.

Chapter 8 shows you what you need to know about the component API for the Java platform-JavaBeansTM. You will see how to write your own beans that other programmers can manipulate in integrated builder environments. (We do not cover the various builder environments that are designed to manipulate beans, however.) The JavaBeansTM component technology is an extraordinarily important technology for the eventual success of Java technology because it can potentially bring the same ease of use to user interface programming environments that ActiveX controls give to the millions of Visual Basic programmers. Of course, since these components are written in the Java programming language, they have the advantage over ActiveX controls in that they are immediately usable across other platforms and capable of fitting into the sophisticated security model of the Java platform.

In fact, Chapter 9 takes up that security model. The Java platform was designed from the ground up to be secure, and this chapter takes you under the hood to see how this design is implemented. We show you how to write your own class loaders and security managers for special-purpose applications. Then, we take up the new security API that allows for such important features as signed classes.

Chapter 10 discusses a specialized feature that we believe can only grow in importance: internationalization. The Java programming language is one of the few languages designed from the start to handle Unicode, but the internationalization support in the Java platform goes much further. As a result, you can internationalize Java applications so that they not only cross platforms but cross country boundaries as well. For example, we show you how to write a retirement calculator applet that uses either English, German, or Chinese-depending on the locale of the browser.

Chapter 11 takes up native methods, which let you call methods written for a specific machine such as the Microsoft Windows API. Obviously, this feature is controversial: Use native methods, and the cross-platform nature of the Java platform vanishes. Nonetheless, every serious programmer writing Java applications for specific platforms needs to know these techniques. There will be times when you need to turn to the operating system's API for your target platform when you are writing a serious application. We illustrate this by showing you how to access the registry functions in Windows.

Definitions

A Java object is an object that is created by a program that was written in the Java programming language.

A Java application is a program that was written in the Java programming language and that is launched by a Java virtual machine (that is, a virtual machine for the Java platform).

Updates

New To This Edition

Cay S. Horstmann teaches at San Jose State University. In addition to co-authoring the best-selling Core Java, he has written two books on C++/object-oriented development, and is a columnist for C++ Report and Java Report.

Errata

View the updates and bug reports for Volumes 1 and 2 of Core Java, Fourth Edition (Java 2).

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.

Overview


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.

Surveys

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.

Newsletters

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.

Security


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

Children


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

Marketing


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.

Choice/Opt-out


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.

Links


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