Copyright ©1996, Que Corporation. All rights reserved. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 West 103rd Street, Indianapolis, IN 46290 or at support@mcp .com.

Notice: This material is excerpted from Special Edition Using Java, ISBN: 0-7897-0604-0. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.

Appendix D - Installation of Java Developers Kit

by Joe Carpenter

Since Java is being billed as "Programming for the Internet", it makes the most sense that one would download the Java Developers Kit (JDK) off of the Internet. There are a number of ways of going about this, the easiest of which is to use your favorite World Wide Web browser to grab it from either the JavaSoft Web site, or one of the several mirrors. In this appendix, we'll cover the basics of downloading the JDK from the JavaSoft site and how to install it on the various supported platforms. We will be assuming that you already have some familiarity with the internet and the world wide Web, and know the basics of using a Web browser.

Downloading the JDK

The first thing you will need to download the JDK is a computer with a connection to the Internet that can use a Web browser. The particular Web browser doesn't really matter all that much, but for our examples we will be using the Netscape Navigator browser.

The second thing you will need is some (well, actually, quite a bit) of free hard disk space on the machine you are planning on downloading the JDK to. Just to download the JDK to a Solaris machine, you will need about 5.4 megabytes worth of free disk space. To uncompress and unpack it, you will need another 10 meg of space. On a Windows 95/NT machine, you will need 4.4 meg for the JDK and about 6.5 meg to uncompress it. On a Macintosh, you will need 2.5 meg of free disk space, and another 6 meg to install it.

If you have some free disk space and a browser handy, you're ready to download. Let's get started!

  1. 1. Launch your net connection (if you need to do that) and your Web browser. If you are unsure of how to do this, consult your system administrator, your friends who know how to use computers, the manuals, or a book on using the World Wide Web.
  2. 2. Point your browser at the JavaSoft JDK download site, at

http://www.javasoft.com/JDK-1.0/installation.html

You will be presented with a list of the currently supported platforms. The platforms currently supported by Sun are -

  1. 3. Click on the link appropriate for your machine. Follow the directions on the page. After reading the copyright and readme files, you can then go ahead and click on one of the links to download the JDK for your machine. If you don't get any response, the server may be overloaded, and you will either have to try again, or try one of the mirror sites.

Here is a list of the URLs for the various JDK releases. These are taken directly from the JavaSoft site. These are provided in case the JavaSoft site is unavailable, or if you want to use normal FTP to get the files.

If you have a platform that is not listed above, there may or may not be a port for your particular machine, and it will not be supported by Sun. For information on obtaining or helping develop third party ports of the Java Developers Kit for your particular platform, try the Java External Related Mailing Lists and Resources page at

http://www.javasoft.com/Mail/external_lists.html

This page has lists for resouces and ports outside of Sun, such as the DEC Alpha, Amiga and Linux ports.

4. Wait while it downloads. The JDK is a pretty big file, and downloading is going to take a while. How long it takes depends on how fast your connection is, the user load on the ftp server at that particular moment, the network load on the internet at the time of day you are downloading the file, the beating of a butterfly's wings somewhere on the planet, sunspots, blind luck, and a large number of other factors that are even more difficult to predict. If the file transfer is going too slow for your taste, try connecting at another time. Depending on where you are on the planet, good times to connect will vary, again depending on many of the same factors as control the transfer rate.

Hopefully, you've now got the JDK for your machine on your hard disk. Now you are ready to install it, so take a deep breath, get up, walk around the room, sit back down, and dive into the next section, Installing Java.

Installing Java

Now that you know a little about Java, and you know where to get it, you'll probably want to install it on your computer so you can start using it.

This section focuses on Java installation, including instructions for:

The Solaris Installation

These instructions are for the JDK only. If you have a Java package from a third-party provider, please refer to the instructions provided with your package.

The JDK is normally distributed as a compressed tape archive (a file with a .tar.Z extension); the name of the file indicates its version.

It is probably well worth your while to archive your current installation, either through the use of tar or your standard system backup process, prior to beginning installation of a new version.

  1. Choose a directory for the installation. These instructions assume an installation location of /usr1/java. If you choose a different base directory, simply replace usr1 with the name of your installation directory. For example, if you choose to install under your home directory, everywhere you see usr1, replace it with ~ or $HOME.

Do not install the JDK over a previous release! Especially if the previous release is one of the pre-beta or beta 1 versions.

Rename the java directory with a command similar to:

mv java java.old

If the installation fails for any reason, you can restore the previous version directly from java.old. Otherwise, after the installation is complete, you can move any additional files, such as documentation, from your old installation into your new installation before removing it from your system.

  1. Verify that you have write permissions for the installation directory. Use this command to check the current permissions:
ls -ld /usr1
  1. The options to the ls command specify long listing, which includes information about ownership and permission, and also specifies to ls to not list the contents of the directory, which is the default. For more information about the ls command, see your system manuals.
  2. The output of the command should be similar to the following:
drwxr-xr-x  root  other  512    Feb 18  21:34   /usr
  1. In this case, the directory is owned by root (the system administrator), and neither the group other nor the general user community have permission to write to this directory. If you run into this situation, and you are not root, you will need the assistance of your system administrator if you want to install in that directory.
  2. Move or copy the JDK distribution file to /usr1.
  3. Extract the JDK with this command:
zcat JDK-1.0-solaris.tar.Z | tar xvfB -
  1. The zcat command prints an uncompressed version of the compressed file to standard output. The pipe command passes the output of zcat into the input of tar. The options on tar tell it to extract files, be verbose (print messages saying what is being extracted), read from the specified file (- specifies standard input), and expect the input to come from a pipe.
  2. Verify that the following subdirectories were created under /usr1:
  3. Set your PATH environment variable:
  1. for the C shell and its derivatives use
setenv PATH $PATH:/usr1/java/bin
  1. for the Korn shell and its derivatives use
PATH= $PATH;/usr1/java/bin
export PATH
  1. Set your CLASSPATH environment variable:
  1. for the C shell and its derivatives use
setenv CLASSPATH /usr1/java/lib/classes.zip
  1. for the Korn shell and its derivitives use
CLASSPATH= CLASSPATH /usr1/java/lib/classes.zip
export CLASSPATH

Rather than set these variables from the command line each time, you probably should add the commands to set the PATH and CLASSPATH variables in your shell resource file-.shrc, .cshrc, .profile, and so on. If you are a system administrator installing the JDK as a network development tool, you may want to add these parameters to the default configuration files.

Windows Installation

These instructions are for the JDK only. If you have a Java package from a third-party provider, please refer to the instructions provided with your package.

You need Windows 95 or Windows NT to run Java; it will not run under Windows versions 3.0, 3.1, or 3.11-including Windows for Workgroups.

Why can't they make Java work under Windows 3.x?
At the time of this writing, no one has had the time, much less the patience, to produce a production-quality version of Java for earlier versions of Windows. There are several reasons for this, but the biggest ones seem to be these:
difficulty in creating a multi-threaded environment under an operating environment that does not support pre-emptive multitasking
TCP/IP support
the 8.3 file format requires a rewrite of the Java interpreter, which expects certain file extensions

The JDK is normally distributed as a self-extracting compressed file; the name of the file indicates its version.

It is probably well worth your while to archive your current installation, either through the use of PKZIP or your standard system backup program, prior to beginning installation of a new version.

  1. Choose a directory for the installation. These instructions assume an installation location of c:\java. If you choose a different base directory, simply append the appropriate path (and change the drive letter, if appropriate). For example, if you want to install to e:\tools\java, replace c: with e:\tools whenever it shows up in the instructions.

Do not install the JDK over a previous release! Especially if the previous release is one of the pre-beta or beta 1 versions.

Rename the java directory (for example, to oldjava) using the Explorer in Windows 95 or File Manager on Windows NT. If the installation fails for any reason, you can restore the previous version directly from oldjava. Otherwise, after the installation is complete, you can move any additional files, such as documentation, from your old installation into your new installation before removing it from your system.

  1. If you plan on installing to a networked drive, make sure you have permission to write to the desired directory.
  2. Move or copy the JDK distribution file to c:\.
  3. Extract the JDK by running the self-extracting program (double-clicking the icon in Explorer or File Manager works just fine).
  4. Verify that the following subdirectories were created on drive c:
  5. Add c:\java\bin to your PATH statement in your autoexec.bat file:
set PATH=c:\windows;c:\dos;...;c:\java\bin
  1. Set your CLASSPATH environment variable in your autoexec.bat file:
set CLASSPATH=c:\java\lib\classes.zip

If you want to squeeze a little more performance out of Java (at the cost of a little more disk space), move the classes.zip file to c:\java\classes (you need to create this directory), and use PKUNZIP to extract the files. You can then remove the classes.zip file.

If you choose this option, you will need to change your CLASSPATH environment variable to c:\java\classes.

  1. Reboot your computer for the environment variables to take effect.

Macintosh Installation

These instructions are for installing the JDK only. If you have a package from a third-party developer, please refer to the instructions provided with your package.

The JDK is normally distributed as a stuffed, bin-hexed archive (a file with a .hqx.sit extension). The file version is indicated in its name. This version runs on '040 generation Macs as well as PowerPCs.

Currently, there is only one version of the JDK available for the Mac (1.0b1). This version runs on both '040 and PPC class machines. As newer versions are released, you will want to install them; make sure to archive your current version before installing a newer version.

  1. After following the above instructions for downloading the MacJDK, you should have an installer titled "MacintoshJDK1.0b1.sea". Double click on this installer, and it will launch into a fairly standard Macintosh installer dialog.

The Macintosh allows users to name directories and files in a manner that chokes UNIX. This includes the naming of folders with slashes (/). This causes problems with the JDK because when the JDK attempts to locate your files, it uses a mixed UNIX/Mac method of tracking paths. Thus, a slash in the name of a folder is interpreted as a change of directory.

UNIX also has a few problems with names that include spaces. As of this release, you should follow the UNIX file and directory naming conventions used by the developers. That means you shouldn't use spaces, slashes, asterisks, and most other punctuation characters in your file and directory names. You can, however, use as many periods as you want, and the filename can be as long as you want it (as long as it's less than 32 characters long).

  1. In the lower left hand corner of the installer dialog, there is a box labeled "Install Location". From that dialog, you can specify where you want to install the JDK. After selecting the appropriate drive and directory, you can then click on the "Install" button to run the installer. It will put all of the Mac JDK in a folder called MacJDK1.0b1 at whatever location you specified in the installer. The default installation location is the root level of your startup disk.
  2. You now have a working copy of the JDK on your hard drive folder. This includes two essential programs: the Java Compiler and the Applet Viewer. You are now ready to move onto the next (and much more fun) parts of Java development.

QUE Home Page

For technical support for our books and software contact support@mcp.com

Copyright ©1996, Que Corporation