Core Java(TM) 2, Volume I--Fundamentals (7th Edition) (Core Series) (Core Series)
The most complete and up-to-date versions of the Java 2 Standard Edition (J2SE) are available from Sun Microsystems for Solaris, Linux, and Windows. Versions in various states of development exist for the Macintosh and many other platforms, but those versions are licensed and distributed by the vendors of those platforms. Downloading the JDK
To download the Java Development Kit, you will need to navigate the Sun web site and decipher an amazing amount of jargon before you can get the software that you need. You already saw the abbreviation JDK for Java Development Kit. Somewhat confusingly, versions 1.2 through 1.4 of the kit were known as the Java SDK (Software Development Kit). You will still find occasional references to the old term. Next, you'll see the term "J2SE" everywhere. That is the "Java 2 Standard Edition," in contrast to J2EE (Java 2 Enterprise Edition) and J2ME (Java 2 Micro Edition). The term "Java 2" was coined in 1998 when the marketing folks at Sun felt that a fractional version number increment did not properly communicate the momentous advances of JDK 1.2. However, because they had that insight only after the release, they decided to keep the version number 1.2 for the development kit. Subsequent releases were numbered 1.3, 1.4, and 5.0. The platform, however, was renamed from "Java" to "Java 2." Thus, we have Java 2 Standard Edition Development Kit version 5.0, or J2SE 5.0. For engineers, all of this might be a bit confusing, but that's why we never made it into marketing. If you use Solaris, Linux, or Windows, point your browser to http://java.sun.com/j2se to download the JDK. Look for version 5.0 or later, and pick your platform. Sometimes, Sun makes available bundles that contain both the Java Development Kit and an integrated development environment. That integrated environment has, at different times of its life, been named Forte, Sun ONE Studio, Sun Java Studio, and Netbeans. We do not know what the eager beavers in marketing will call it when you approach the Sun web site. We suggest that you install only the Java Development Kit at this time. If you later decide to use Sun's integrated development environment, simply download it from http://netbeans.org. After downloading the JDK, follow the platform-dependent installation directions. At the time of this writing, they were available at http://java.sun.com/j2se/5.0/install.html. Only the installation and compilation instructions for Java are system dependent. Once you get Java up and running, everything else in this book should apply to you. System independence is a major benefit of Java. NOTE
Setting the Execution Path
After you are done installing the JDK, you need to carry out one additional step: add the jdk/bin directory to the execution path, the list of directories that the operating system traverses to locate executable files. Directions for this step also vary among operating systems.
Here is how you test whether you did it right: Start a shell window. How you do this depends on your operating system. Type the line java -version and press the ENTER key. You should get a display such as this one: java version "5.0" Java(TM) 2 Runtime Environment, Standard Edition Java HotSpot(TM) Client VM
If instead you get a message such as "java: command not found", "Bad command or file name", or "The name specified is not recognized as an internal or external command, operable program or batch file", then you need to go back and double-check your installation. Installing the Library Source and Documentation
The library source files are delivered in the JDK as a compressed file src.zip, and you must unpack that file to get access to the source code. We highly recommend that you do that. Simply do the following:
TIP
The documentation is contained in a compressed file that is separate from the JDK. You can download the documentation from http://java.sun.com/docs. Several formats (.zip, .gz, and .Z) are available. Choose the format that works best for you. If in doubt, use the zip file because you can uncompress it with the jar program that is a part of the JDK. Simply follow these steps:
Installing the Core Java Program Examples
You should also install the Core Java program examples. You can download them from http://www.phptr.com/corejava. The programs are packaged into a zip file corejava.zip. You should unzip them into a separate directory we recommend you call it CoreJavaBook. You can use any zip file utility such as WinZip (http://www.winzip.com), or you can simply use the jar utility that is part of the JDK. If you use jar, do the following:
Navigating the Java Directories
In your explorations of Java, you will occasionally want to peek inside the Java source files. And, of course, you will need to work extensively with the library documentation. Table 2-1 shows the JDK directory tree.
The two most useful subdirectories for learning Java are docs and src. The docs directory contains the Java library documentation in HTML format. You can view it with any web browser, such as Netscape. TIP
The src directory contains the source code for the public part of the Java libraries. As you become more comfortable with Java, you may find yourself in situations for which this book and the on-line information do not provide what you need to know. At this point, the source code for Java is a good place to begin digging. It is reassuring to know that you can always dig into the source to find out what a library function really does. For example, if you are curious about the inner workings of the System class, you can look inside src/java/lang/System.java. |