Preface

To the Reader

The book you have in your hands is the second part of the third edition of Core Java. The first edition appeared in early 1996, the second in late 1996. 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 to us that a one-volume treatment of all the features of Java that a serious programmer needs to know was no longer possible. Hence, we decided to break up the third edition into two volumes; the second volume is what you are looking at.

The first volume covered the essential features of the language; this volume covers the advanced topics that a Java programmer will need to know so that he or she will (we hope) be in a position to do commercial Java development. Thus, as with the first volume and the previous editions of this book, we still are targeting programmers who want to put Java to work on real projects.

Please note: If you are an experienced Java developer who is comfortable with the new event model and the other language features, such as inner classes, that were added to Java 1.1, 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 Java 1.1 book.)

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 page at http://www.horstmann.com with an FAQ, bug fixes, and workarounds. Strategically placed at the end of the Web page (to encourage you to read the previous reports) is a Java applet that you can use to report bugs or problems and to send suggestions for improvements to future editions.

About This Book

First, except for Chapter 1, which is a thorough discussion of input and output in Java 1.1, the remaining chapters in this book can almost certainly be read independently of each other—only occasional backtracking will be needed at most. We suggest reading Chapter 1 first and then turning to whatever topic interests you the most in the remaining chapters. Here are short descriptions of the various chapters.

Input/output in Java is handled through what Java calls streams, which are conceptually the same as the similarly named feature of C++. Streams let you deal in a uniform manner with the large number of possible ways of getting input from any source of data that can send out a sequence of bytes and then sending it to any destination that can also work with a sequence of bytes. In particular, we include detailed coverage of the new Reader and Writer classes in Java 1.1, which make it easy to deal with Unicode; and we include the new object serialization mechanism in Java 1.1, which makes saving the state of an object almost trivial.

Chapter 2 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.

Chapter 3 covers one of the most exciting APIs in Java: the one for networking. Java makes it phenomenally easy to do sophisticated 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 the JDBC, the Java database connectivity API. We show you how to write useful programs to handle realistic databases, 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 certainly 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 a net or running in separate processes on a single machine. We also show you where the rallying cry of “objects everywhere” can realistically be used.

Chapter 6 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 Java programmer’s toolkit. These features include the image manipulation API and the (partially implemented) cut-and-paste API. We actually take the cut-and-paste API one step further than JavaSoft itself did: We show you how to cut and paste Java objects between different Java programs via the system clipboard.

Chapter 7 shows you what you need to know about the new component API for Java—JavaBeans™. We show you what you need to know in order to write your own Java beans. (We do not cover the various builder environments that are designed to manipulate beans, however.) The JavaBeans™ component technology is an extraordinarily important technology for the eventual success of Java because it can potentially bring the same ease of use to Java programming environments that ActiveX™ controls give to the millions of Visual Basic™ programmers out there. Of course, since these components are written in Java, they have the advantage over ActiveX controls in that they are immediately cross-platform and immediately capable of fitting into the sophisticated security model of Java.

In fact, Chapter 8 takes up that security model. Java 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 9 discusses a specialized feature that we feel can only grow in importance: internationalization. Java is one of the few languages designed from the start to handle Unicode. 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 10 takes up native methods, which let you call methods written for a specific machine such as the Windows API. Obviously, this feature is controversial: Use native methods, and the cross-platform nature of Java 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.

Appendix I contains instructions for installing the software and example code from the CD-ROM.

Conventions

As is common in many computer books, we use courier type to represent computer code.

Note

Conventions

There are many C++ notes that explain the difference between Java and this language. You can skip over them if you aren’t interested in C++.

Note

Conventions

Notes are tagged with a “notepad” icon that looks like this.

Note

Conventions

Java comes with a large programming library or Application Programming Interface (API). When using an API call for the first time, we add a short summary description, tagged with an API icon. These descriptions are a bit more informal, but also a little more informative than those in the official on-line API documentation.

Programs whose source code is on the CD-ROM are listed as examples, for instance, Example 15-8: WarehouseServer.java refers to the corresponding code on the CD-ROM.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.208.206