Fullness of the Spirit, The
PrefaceWhy We Are HereThe Java language is maturing and growing by leaps and bounds. With that maturation and  growth, we've found more than enough new material to sink our teeth into with this edition of Java by Example. Our approach has never been to explore every nook and cranny of the Java language. Rather, we've tried to concentrate on topics that we deem to have the greatest utility for programmers making the transition to Java and to provide fairly detailed examples of those topics. Our primary focus in this edition is to explore the Java inner classes mechanism, reflection, and the collection classes. We'll try to help burgeoning Java programmers comprehend the utility of these in practical use. Where appropriate, we also try to show powerful programming techniques enabled by Java.We'll also revisit Java native methods. In light of the Java Native Interface (JNI) introduced in the JDK, there's now a much more formal and clean way to interface Java applications with existing programs than with the original native methods mechanism.Two areas of focus that, to our dismay, caused some confusion in the previous edition, namely the Java Remote Method Invocation (RMI) mechanism and the Java Database Connectivity (JDBC), will receive a slight make-over in this new edition. The last time around, we worked with pre-release versions of RMI and JDBC. However, we were confounded by the fact that the implementations for those parts of the language changed between the pre-release and the official JDK  release. With many apologies to users miffed by our attempt to bet on the stability of the pre-release, we'll revisit these two key features of the language.Although we update our applets portion of Java by Example, we are consciously not taking on the scope of changes in the JDK 1.2 Abstract Windowing Toolkit (awt). There is simply too much there to try to cover in a book adequately. In reality, the best way to grasp the complexities of the AWT is to read Graphic Java, which comprehensively covers the awt.The structure of the book is consistent with previous editions. Part 1 covers basics of the Java language, showing how to implement standard programming constructs such as reading and writing to a file, declaring arrays, allocating and initializing memory, using the Java RMI and JDBC, and so on. Part 2 covers basics of applet writing, specifically for programmers who are concentrating on programs that will run within a web browser. Part 3 covers a myriad of useful details that don't really fit with the focus of the first two parts. AudienceThis is not a book about authoring on the world-wide web, writing common-gateway interface (CGI) scripts, or maintaining web servers. This is a book for intermediate to experienced programmers interested in learning Java. Because of the sheer number of C and C++ programmers ready to make the transition to Java, we pay special attention to Java as it relates to C and C++.  For Mac ProgrammersThere seems to be some confusion in the Macintosh community, from which we've had requests for Mac editions of Java by Example. This is actually counter to one of the great advantages of Java—it's platform independence. Granted, there are some restrictions on the Macintosh, namely, the 31 character file name limit imposed by MacOS. To address this issue, we've provided the compiled programs in zip format for easy execution on the Mac.We hope these modifications ease use of this material by the Mac programming community.Meanwhile, to keep an eye on Java updates for Mac OS, check out apple/macos/java/For C ProgrammersFor C programmers who are coming to an object-oriented (OO) language for the first time, we provide an appendix that discusses the essential constructs used in object-oriented programming. Note, however, that this discussion is simply an introduction to OO as it relates to Java. There are several books and courses dedicated to OO programming, and novice OO programmers may want to consult some of these for more information.Internet Sources of InformationThere are several online sources of information on Java.To subscribe, send mail to majordomo@xcf.berkeley. The subject must be blank, and the body of email must be the following:subscribe advanced-javaendFrom these newsgroups, mail aliases, and web sites, you'll be able to locate countless other resources, tutorials, Frequently-Asked-Questions (FAQs), and online magazines dedicated to Java.For updates about this book and information about other books in the Sun Press Java Series, look on the web at:sun/books/java_series.htmlApplets, Applications, and Programming AidsThe CD that accompanies this book includes several Java programs that you can use, modify, or simply study to help you learn the language. These programs include:Applets that show simple to complex use of the Java graphics library, multiple threads, and multimedia.Applications that show basic input/output, interfaces, memory use, and more.Programs such as a public class parser that you can use to extract information about Java classes or your program's classes. We provide these as simple aids you can use to better learn and understand the Java language.Many of these programs are discussed throughout the book, but some are presented simply for you to examine, play with, or mimic. Feel free to borrow or adapt these for your own purposes. Java by Example CD ContentsThe CD accompanying this book includes the applets and applications referred to within this book, as illustrated in Table P-3. These are stored in the Code.zip file. Table P-3 CD ContentsDirectoryContentsapplets This directory contains several sample applets, including the supporting audio and image files in .au and .gif format, respectively. This directory also includes sample HTML files that can be used to view the applets with the Java appletviewer.applications This directory contains several illustrative Java applications, some of which are described in the book, some of which are just provided for your use.classes.zip The applet and application class files referred to in the book in zip format.You do not have to copy the CD contents to run the applications and applets on it. To run the programs from the CD, extract the Code.zip file, set the CLASSPATH environment variable to point to the Java Development Kit classes.zip file and the Java by Example classes.zip file on the CD.--This text refers to an out of print or unavailable edition of this title.