back to resources page

Setting up Java 1.5 on Atlas

by T. S. Purewal

By default, your atlas account is set up to use Java 1.4.2 -- you can check this by going to the command prompt and typing "java -version" at the command prompt. If it doesn't say that you are using Java version "1.5.0", then you need to change your path so that it uses the newer version.

In Unix, when you type in a command, your command line shell (which is called csh pronounced "cash") searches your path environment variable to find the program that you requested. If it cannot find the program, it outputs a "command not found" error. You can see the contents of your path environment variable by typing "echo $path" at the command prompt. The "$" in front of the word "path" is letting the shell know that you want it to echo the contents of the path environment variable, rather than simply echo the word "path" back to you (try typing "echo path").

When you echo the path, you will see a list of directories seperated by spaces. You should see something like "/usr/local/java/j2sdk1.4.1/bin" in your path. This is the version of java that you are using. You need to change your path environment variable so that it uses the 1.5 sdk instead.

You can change the path variable each time you log on to atlas, but it would be better to change it so that it automatically uses java 1.5 every time you log on. To do this, we need to change our .cshrc file. The .cshrc file is the resource file for your shell, and it is read automatically every time you log on to atlas. The purpose of this file is to set up all of your environment variables. It is located in your home directory.

First, type "cd ~" to change directories to your home directory. Next type "ls" to list the contents of your directory. When you do this, you won't see your .cshrc file. This is because the .cshrc file is preceded by a "." which makes it hidden unless you explicitly look for it. Type "ls -a" to list all files in the directory, including the hidden ones. Then you should see it.

The next thing you want to do is to make a copy of it (so if it gets messed up, you can easily restore it). To do this, simply type "cp .cshrc .cshrc.BACKUP". This will create a backup copy of your .cshrc file.

The next step is to actually open your .cshrc file using a text editor (you should be able to open and edit a file in vi). Once it is open, scroll down to the line that says "set path = ( ... )". That line sets your path environment variable.

You'll want to add the following directory to your path - "/usr/local/jdk1.5.0/bin". This is the directory that stores the java 1.5 binaries (programs like "javac", "java", and "javadoc"). It is important that you add it to your path BEFORE any other java directory, because when you type "java" on the command line, its going to execute the first "java" it comes to in your path. I put it as the first directory in my path. After you are finished editing the line, it should look something like this:

set path=( /usr/local/jdk1.5.0/bin /usr/local/java/j2sdk1.4.1/bin /opt/sfw/bin /usr/local/bin /usr/bin /opt/sfw/bin .)

Note that your line may look different if you have different directories in your path. Don't remove any directories from your path - including the old java path! If you feel that you have changed your path properly, save the file and exit your text editor.

When you return to the command line, you'll want your shell to read your .cshrc file again so that it can reset your path variable to the new version. Simply type "source .cshrc", which will force the computer to do so.

Now type "java -version" and it should say that you are using java 1.5.0!