1. Do pre-installation checks
Before proceeding further, check that you have downloaded the full, uncorrupted software file:
jdk-1_1_6_009-solsparc.bin |
10,143,191 bytes |
jdk-1_1_6_009-solx86.bin |
9,738,570 bytes |
The JDK software file and the JDK documentation file (available for download from step 2 of the JDK download page) should be unpacked in the same directory. Unpacking them in the same directory ensures that links between HTML files will work properly.
You can download and install the software file and the documentation file in any order. If you've already downloaded and installed the JDK documentation, you must unpack the JDK software file in the same directory from which you unpacked the documentation. For example, if you installed the JDK software at /usr/local/, then you should place the downloaded JDK software file in /usr/local/ before proceeding.
2. Unpack the downloaded software file
If you unpack the software or documentation in a directory that contains a directory named jdk1.1.6, the new software will overwrite files of the same name in that jdk1.1.6 directory. Please be careful to rename the old directory if it contains files you would like to keep.
In a shell window, execute the commands listed below. Note that this temporarily creates a README file in the current directory (which will overwrite any README file you might have).
% chmod a+x jdk-1_1_6_009-solsparc.bin
% ./jdk-1_1_6_009-solsparc.bin
% chmod a+x jdk-1_1_6_009-solx86.bin
% ./jdk-1_1_6_009-solx86.bin
This will bring up a license for you to read. If you agree, type yes, hit Return, and it will create a directory called jdk1.1.6 containing the JDK software, with the directory structure shown below.
Included in the unpacked files is a file lib/classes.zip. DO NOT UNZIP THE CLASSES.ZIP FILE. This file contains all of the core class binaries, and must remain in its zipped form for the JDK to use it.
JDK Directory Tree
The JDK software and documentation directories will have the following structure. The docs directory and its contents will be installed when you download and unpack the JDK documentation.
jdk1.1.6
_________________________|________________
| | | | | | | | | | |
README | | | bin lib | demo | docs |
CHANGES | | | | include | src | |
COPYRIGHT | | | | |
LICENSE index.html
The src directory shown above originally appears as a src.zip file in the Solaris installation, which you may manually unzip to obtain access to the source code for the JDK class libraries. However, you must use an unzip program that maintains long files names. Such unzip utitilities may be found at UUNet FTP Site.
3. Delete the original files you downloaded
If you want to recover disk space, delete the file you downloaded.
4. Update path and environment variables
It is possible for you to run the JDK without modifying any system environment variables (such as PATH or CLASSPATH) or modifying your startup file (~/.cshrc). However, you should test that CLASSPATH is not set, and most developers set PATH as a convenience.
Set the path variable if you want to be able to run the executables (javac, java, javadoc, etc.) from any directory. If you don't set the path variable, you need to specify the path to the executable when running it. The path variable is merely a convenience to the developer and not necessary to set.
% which java
This will print the path to the java tool, if it can find it. set path=($path /usr/local/jdk1.1.6/bin)
%
source ~/.cshrc %
which java
If you follow the default installation, you do not need to set CLASSPATH, because the shell scripts automatically set it for you. If your CLASSPATH is currently not set, you can skip this step.
If you have previously set the CLASSPATH variable and want to unset it, you normally need to change the current value (at the command line) and the startup value (in your startup file or script). To see if it is currently set, type:
% echo $CLASSPATH
If it is set, you can unset the current value by typing:
% unsetenv CLASSPATH
Also open your startup file (~/.cshrc) or script and remove the path to the JDK classes from the CLASSPATH environment variable if you want the change to be permanent.
The CLASSPATH tells the Java Virtual Machine* and other Java applications (which are located in the "jdk1.1.6/bin" directory) where to find the class libraries, such as classes.zip file (which is in the lib directory). By default, the java tools temporarily append the following to whatever CLASSPATH you have explicitly set in your startup file:
.:[bin]/../classes:[bin]/../lib/classes.zip
where [bin] is substituted by the absolute path to the jdk1.1/bin directory. Therefore, if you keep the bin and lib directories at the same directory level (that is, if they have a common parent directory), the Java executables will find the classes. You need to set the CLASSPATH only if you move classes.zip or want to load a different library (such as one you develop).
Troubleshooting the Installation
5. Start using the JDK!
Your computer system should now be configured and ready to use the Java Development Kit. You start a tool by typing its name at shell window command line, with a filename as an argument. If you didn't set the path variable to point to the tools in step 4, you must specify the path to a tool by typing the path in front of the tool.
For example, if the JDK is installed at /usr/local/jdk1.1.6, you can run the JDK's complier, javac, by doing either of the following:
Type: /usr/local/jdk1.1.6/bin/javac myfile.java
-or-
Add /usr/local/jdk1.1.6/bin to your path statement
Type: javac myfile.java
% cd jdk1.1.6/demo/TicTacToe
% appletviewer example1.html
Documentation for all the JDK tools can be found in your installed JDK directory structure at jdk1.1.6/docs/tooldocs/solaris/index.html or on the tools reference page on the JavaSoft website.
% setenv
CLASSPATH .:/usr/local/jdk1.1.6/lib/classes.zip
Error Message: Could not read properties file
If you get this error message when running one of the JDK tools such as the appletviewer, it may mean that your JAVA_HOME environment variable is not set properly. Normally, you shouldn't have to worry about setting JAVA_HOME. However, some Java IDEs set the JAVA_HOME variable to a value that won't allow you to run from the JDK. Check to see if your JAVA_HOME value has been set by using the echo command:
% echo $JAVA_HOME
If a value is set for JAVA_HOME, unsetting it should allow you to run the JDK tools. You may want to make a note of the current JAVA_HOME setting before you unset it, in case you want to restore it later. You can unset the JAVA_HOME environment variable as follows:
% unsetenv JAVA_HOME
If you still cannot run the JDK tools after unsetting JAVA_HOME, you can try setting JAVA_HOME to the absolute path of the jdk1.1.6 directory that was created when you installed the JDK. For example, if you installed JDK 1.1.6, and the directory jdk1.1.6 has the path /usr/local/jdk1.1.6, you can try setting JAVA_HOME as follows:
% setenv JAVA_HOME /usr/local/jdk1.1.6
As long as you have not disturbed the bin and lib directories that are immediately below the jdk1.1.6 directory, you should be able to run the JDK tools.
Error message: Invalid JAVA_HOME
This error message indicates that your JAVA_HOME environment variable has been set to a value that is not compatible with running the JDK tools. You should try to correct the problem by following the suggestions given above under "Error Message: Could not read properties file".
Running Applets With The Appletviewer
AppletViewer allows you to run one or more Java applets that are called by reference in a web page (HTML file) using the APPLET tag. The AppletViewer finds the APPLET tags in the HTML file and runs the applets (in separate windows) as specified by the tags.
AppletViewer is for viewing applets. It cannot display an entire web page that contains many HTML tags. It parses only the APPLET tag and no other HTML on the web page.
To run an applet with appletviewer, you go to a command line for your operating system and run appletviewer, passing in the filename or URL of the web page as its argument.
Here is an example of how to invoke AppletViewer on a file-based web page in Windows. Go to a DOS prompt, change to the "jdk1.1.6" directory and then execute:
%
bin/appletviewer demo/GraphLayout/example1.html
%
bin/appletviewer #
Debugging Programs With The Java Debugger (Jdb)
You can debug applets using the -debug option of appletviewer. When debugging applets, it's best to invoke appletviewer from the directory that contains the applet's HTML file. For example, on the PC:
cd demo/TicTacToe ../../bin/appletviewer -debug example1.html
You can find documentation on the debugger and its API at:
#
*As used on this web site, the terms "Java virtual machine" or "JVM" mean a virtual machine for the Java platform.