Installing the J2SDK

 < Free Open Study > 



The first step is, as always, to download the software. It can be found under the Products and APIs section of Sun's Java home page: http://www.java.sun.com. You'll need to download the Java 2 SDK for Linux. Since this is a proprietary software product, an installation from source code is not available as an option. Therefore, it's important that you make sure that the software will run on your actual distribution; the download page lists requirements that the distribution must have (which typically boils down to whether the distribution has the required version of the GNU glibc library package). Note that even though the source code is available for a no-cost download, the license isn't an open source license and building the code is no mean feat; this isn't really an option for end users such as you.

At the time of this writing, the current J2SDK version was 1.4, so this example assumes you are installing that version. In practice, however, it's common for Java developers to switch between different versions of the J2SDK, and even switch between different JDKs. For example, they may need to support a specific version of the J2SDK (which may or may not be the latest and greatest from Sun). Also, developers sometimes need to switch to another vendor's JDK implementation; IBM also has a version, and sometimes it's useful in debugging Java software to switch between the IBM and Sun versions.

This requirement implies that at any given time a system may need more than one JDK installed on it. As discussed in the section "Deciding on a Destination" in Chapter 7, this situation makes it more appropriate to install the software in /opt, rather than /usr/local. For example, a system might have /opt/ibm-jdk-1.3 and /opt/sun-j2sdk-1.4 both installed simultaneously. However, there's more to Java than just the JDK; developers and users of Java software also need a wide variety of Java libraries (called Java Archive files or JAR files) in order to actually use most software. Thus, this example takes the /opt technique a step further: the software will be installed in /opt/java rather than simply /opt. This will be discussed in more detail as this section continues; for now, it's enough to say that the installation directory is /opt/java/sun-j2sdk-1.4.

The next step is to physically extract the JDK. The package is distributed as a shell script, actually. This may seem somewhat strange to those of you unfamiliar with it; security-conscious users may even be (justifiably!) suspicious of packages that must be executed in order to install them. However, this package is fairly innocuous. It is a shell archive (shar) file. This format is similar in concept to a Tape Archive (tar) file, ubiquitous on Unix systems and probably already familiar to you. However, a shar file is actually encoded into a shell script, unlike a tar file, which is simply a binary data file. There are generally two reasons for using a shar file instead of a tar file: One is that since it's a shell script, it's simply an ASCII text file, and so is easier to e-mail than a binary tar file would be.

The other reason for using a shar file-and the one that Sun is interested in- is that since the format is a shell script, the packager can include a script to be run when the package is extracted. In the case of the JDK, Sun uses this capability to display a copy of the software license to which you are required to agree before the shar file will continue with the extraction. Thus, when the JDK distribution is unpacked, the license will be displayed, and you must agree to it before continuing.

At any rate, the JDK distribution file can be extracted simply by executing the file. However, the shell script extracts the contents into the current directory, so it's important to move to the parent directory of the desired ultimate location! An additional potential nuisance is that the JDK will extract itself into a specifically named directory: j2sdk1.4. If there's already a directory by that name (which may be the case if more than one JDK is installed), then its contents will be overwritten, so check carefully before proceeding! Thus, it may be advisable to perform the extraction in a directory other than the destination, such as /tmp. At any rate, here are the steps to extract the J2SDK (assuming that the J2SDK distribution has been downloaded into /tmp/[filename]):

 % mkdir /tmp/jdk; cd /tmp/jdk % sh /tmp/[filename] % mkdir -p /opt/java % mv j2sdk1.4 /opt/java/sun-j2sdk-1.4 

After performing the second step, you must read and agree to the license, and then the contents will be extracted.

The -p parameter to the mkdir command causes it to silently return, rather than fail with an error, if the directory already exists; consult the manual page for mkdir for more information.

At this point, the Sun Java 2 SDK version 1.4 will be installed in /opt/java/sun-j2sdk-1.4. The reason that the name was changed from the default name of j2sdk1.4 is because more than one version of the J2SDK may need to be installed on the system at the same time. This name change makes it easier to manage the versions installed. For example, version 1.3 of IBM's JDK implementation could be installed alongside the Sun version in the directory /opt/java/ibm-jdk-1.3. This naming scheme makes it easier to keep track of which vendor's software is installed in which directory.



 < Free Open Study > 



Tuning and Customizing a Linux System
Tuning and Customizing a Linux System
ISBN: 1893115275
EAN: 2147483647
Year: 2002
Pages: 159

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net