Background: The CLASSPATH in a UNIX-based system is an environment variable that is a list of directories that the operating system looks in to find library classes and modules. For example, to compile Java, the Java *.class files must be in your CLASSPATH.
To set your CLASSPATH: For bash shell use - "export CLASSPATH=$CLASSPATH:/java/classes"
Sometimes .jar files also need to be included into the CLASSPATH. A good example of doing this is for XOM (a new XML object model available under LGPL) is:
For bash shell use - "export CLASSPATH=$CLASSPATH:~/xom/xom-1.1.jar"
I must say however, the problem with the above method is that it only sets this variable for your current bash session! Therefore, what you likely want to know is how to set this variable permanently,and thus accessible in all subsequent sessions. To do this, go to your user home directory ("cd ~/" should do the trick), in it should be the file .bashrc, open this file (I used Vi), scroll down to where the CLASSPATH variable is set and append the relevant directory (I used ~/xom/xom-1.1.jar), then save and close. (Ensure you don't overwrite the last line after the CLASSPATH is set, i.e. "export CLASSPATH".. if this is not exported, this WILL lead to problems.) Now, for every new session of bash, the added class directory or .jar file will be referenced. You can try "echo $CLASSPATH" to test.
The main reference for this article was is Setting your Classpath at Linux Headquarters. At that link you can also find information on setting the PATH variable.
Enjoy!