added the following words at the end of /etc/profile depended on your own system:
export JAVA_HOME=/usr/local/java/jdk1.6.0_31
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
added the following words at the end of /etc/profile depended on your own system:
export JAVA_HOME=/usr/local/java/jdk1.6.0_31
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH