Setting the PATH and CLASSPATH under Linux
Contact: sales@atlasindia.com
What's a PATH ?
The path is an enviroment variable which tell the operating system which directories to look under for executing a particular command (which would be an executable file) for each user. Each user has a default set of directories configured under the PATH variable and additional directories can be added by user.
Setting your PATH:
First take a look at the following command:
$ env
You should be able to see a list of all the current ENV variables and their values including the current directories in PATH.
Redhat Linux by default uses the bash shell. It also supports the tShell and the cShell.
To make an addition to the path under these 3 systems you do the following:
For the bash shell:
export PATH=$PATH:/usr/sbin/:/usr/local/bin
For the tcsh and csh shell:
set PATH = ($PATH /usr/sbin /usr/local/bin)
You can type out these commands on the command line each time you need the path to be set or you can append the command onto the .bashrc file or the .cshrc file depending on whether you are using bash or tShell or cShell.
To find out which shell you are running, do this:
$ finger username
Where username is the account that you're using.
Note: These are hidden files. So to see them use $ ls -a
What's a CLASSPATH ?
This environment variable is used by the operating system to find library classes. Java uses these at compile time to locate the *.class files.
For the bash shell
export CLASSPATH = $CLASSPATH:/java/classes:/home/username/jclasses
For the tShell and the cShell
set CLASSPATH = ($CLASSPATH /java/classes /home/username/jclasses)
Again, these commands can be typed at the command line each time you logon or appended to the .bashrc file or the .cshrc file in your home directory.