Installation NotesJava 2, Standard Edition, Version 1.2.2 for Linux
|
The installation procedure is simple, and consists of the following steps:
<version number>
For example, if you are downloading update 1.2.2_011, the following
tar command:
% tar xvzf jdk-1_2_2_<version number>-linux-i586.tar.gz
would become:
% tar xvzf jdk-1_2_2_011-linux-i586.tar.gz
1. Check the download file size
Before you download a file, notice that its byte size is provided on the download page. Once the download has completed, check that you have downloaded the full, uncorrupted software file.
2. Change to the directory you want to install into.
For example, if you want to install the software in the /usr/local/ directory, then execute:% cd /usr/localUnbundling the software in the next step automatically creates a directory calledjdk1.2.2. Note that if you choose to install the Java 2 SDK into system-wide location such as /usr/local, you must first become root to gain the necessary permissions. If you do not have root access, simply install the Java 2 SDK into your home directory, or a subdirectory that you have permission to write to.Note about the Java 2 SDK doc bundle - You can get the Java 2 SDK documentation bundle from the SDK download page. You should unbundle the Java 2 SDK software bundle and the SDK documentation bundle in the same directory. Unbundling them in the same directory ensures that HTML links between them will work properly. You can download and install the software bundle and the documentation bundle in either order.
3. Extract the contents of the Java 2 SDK
4. Delete the original file you downloaded (Optional)Depending on the format you downloaded, execute the following command(s) in a shell window to extract the contents of the Linux Java 2 SDK:
Or, if you prefer, uncompress and untar the file using 2 separate steps:% tar xvzf jdk-1_2_2_<version number>-linux-i586.tar.gzNote about overwriting files - If you unpack the software or documentation in a directory that contains a subdirectory named jdk1.2.2, the new software will overwrite files of the same name in that jdk1.2.2 directory. Please be careful to rename the old directory if it contains files you would like to keep.% gunzip jdk-1_2_2_<version number>-linux-i586.tar.gz
% tar xvf jdk-1_2_2_<version number>-linux-i586.tar
If you want to recover disk space, delete the file (or files) you originally downloaded.5. Update the PATH environment variable
You can run the Java 2 SDK just fine without setting the PATH variable, or you can optionally set it as a convenience.Should I set the PATH variable?
Set the path variable if you want to be able to run the executables (javac, java, javadoc, etc.) from any directory without having to type the full path of the command. If you don't set the PATH variable, you need to specify the full path to the executable every time you run it, such as:% /usr/local/jdk1.2.2/bin/javac MyClass.javaIs the PATH already set?
To find out if the path is currently set for any java tools, execute:% which javaThis will print the path to the java tool, if it can find it. If the PATH is not set properly, you will get the error:% java: Command not foundHow do I set the PATH permanently?
To set the path permanently, set the path in your startup file.For C shell (csh), edit the startup file (~/.cshrc):
set path=(/usr/local/jdk1.2.2/bin $path)For ksh, bash or sh, edit the profile file (~/.profile):
PATH=/usr/local/jdk1.2.2/bin:$PATHThen load the startup file and verify that the path is set by repeating the "which" command above:For C shell (csh):
% source ~/.cshrc % which javaFor ksh, bash or sh:
$ . $HOME/.profile $ which java
6. Start using the Java 2 SDK!
Your computer system should now be ready to use the Java 2 SDK. In this step, you'll run some simple commands to make sure it is working properly.7. Where Do I Go From Here?You start the compiler, interpreter, or other tool by typing its name at the shell window command line, generally with a filename as an argument. The SDK development tools need to be run from the command line and have no GUI interfaces (except AppletViewer). Double-clicking a tool's file icon, such as
java, will not do anything useful.You can specify the path to a tool either by typing the path in front of the tool each time, or by adding the path to the system as in the previous step. The following assumes the Java 2 SDK is installed at /usr/local/jdk1.2.2, and you have set the path variable. (If you have not, add /usr/local/jdk1.2.2 ahead of the javac and appletviewer commands.)
Compiling a Java class - To run the compiler on a file MyClass.java, go to the prompt window and execute this:
% javac MyClass.javaSee the next section for link to Hello World examples.Running Applets - You can run applets in AppletViewer. Here's an example:
- Use cd to change to the TicTacToe directory that contains the html file
example1.htmlthat embeds an applet:
% cd jdk1.2.2/demo/applets/TicTacToe- Run AppletViewer with the html file:
% appletviewer example1.htmlThis example lets you interactively play Tic-Tac-Toe.
At this point, you will probably want to install the documenation bundle, if you have not already done so. Although you can use the SDK tools without installing the documentation, it makes sense to do so if you are going to do any extensive work. You can get the SDK documentation bundle from the Java 2 SDK download page. Click here for documentation bundle installation instructions.You can also go to:
- README -- For a Linux introduction to the Java 2 SDK
- Hello World application and Hello World applet -- To write and compile a simple class, guided by the Java Tutorial.
To submit comments or suggestions about the Java 2 SDK, please send email to the appropriate engineering team from the list at Java Software email addresses.
|
| ||||||||||||