You can set CLASSPATH and PATH in your user directory or /etc/profile.
JAVA_HOME=/usr/java/jdk1.6.0_10
JAVA_BIN=/usr/java/jdk1.6.0_10/bin
export JAVA_HOME JAVA_BIN
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:/home/frank/
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin
When you use java command to run the *.class file, the system will find the file from CLASSPATH first, if not find, then the system will find it from PWD(primary work directory). When Using "java" command to run the *.class file do not with the suffix(.class), because the system will not run all the class file but just a part of the bytecode.