In this first chapter from the book The Art of Java by Herbert Schildt and James Holmes, the authors highlight certain features of the Java programming language that separate it from other languages. The chapter also covers: memory management, Java's built-in support for multithreading, Java's approach to exceptions as compared to C++, Java's support of polymorphism, and how bytecode enables Java's "Write Once, Run Anywhere" ability and provides security. (ISBN 0-07-222971-3, McGraw-Hill/Osborne, 2003).
Conceptually, computer languages consist of two parts. The first is the language proper, defined by the keywords and syntax. The second is the standard library, which contains a set of classes, interfaces, and methods that are available to the programmer. Although all of the major languages today provide large libraries, the one defined by Java stands out because of the richness and diversity it offers to the programmer. When Java was first created, its library contained a set of core packages, such as java.lang, java.io, and java.net. With each new release of Java, classes and packages have been added. Today, Java gives the programmer access to a truly amazing array of functionality.
Since the beginning, one of the key elements that differentiated the Java library from that provided by other languages was its support for networking. At the time of Java’s creation, other languages, such as C++, did not (and still do not) provide standard library elements that handle networking. By providing classes that easily handled connecting to and using the Internet, Java helped spark the Internet revolution. With Java, the Internet was open to all programmers, not just those that specialized in networking. The functionality in java.net transformed computing.
Another key package of the core Java library is java.awt, which supports the Abstract Window Toolkit (AWT). The AWT enables the programmer to create portable, GUI-based code. That is, by using the AWT classes, it is possible to create a windowed application that uses the various standard GUI elements, such as scroll bars, check boxes, and radio buttons. Because of the AWT, it is possible to create a GUI application that can run in any environment that supports the Java Virtual Machine. This level of GUI portability was unknown prior to Java.
Java’s inclusion of the AWT revolutionized the way programmers thought about the application environment. Before Java, GUI-based programs had to be specifically written for their execution environments. This meant that a Windows program, for example, would need to be substantially recoded to run in an Apple computer. After Java, a programmer could write one program that would execute in both environments. By defining a portable GUI, Java unified the programming environment.
In later years, a lightweight alternative to the AWT was added to Java: Swing. The Swing components are contained in javax.swing and its subpackages. Swing offers the programmer a rich set of GUI components that have enhanced portability. As many of the examples in this book show, both the AWT and Swing give the programmer the ability to produce highly effective, portable GUI-based applications.
Today, the Java library has grown substantially from its initial core. Each new release of Java has been accompanied with additional library support. New packages have been added, and new functionality has been added to existing packages. The Java library has been in a constant state of transformation because it has been responsive to the rapidly evolving computing environment. This ability to adapt and change in short order is part of the genius of Java.
Remember: this is chapter one of The Art of Java, by Herbert Schildt and James Holmes (McGraw-Hill/Osborne, ISBN 0-07-222971-3, 2003). Check it out at your favorite bookstore today. Buy this book now.