vim /etc/profile
export JAVA_HOME=/demo/src/jdk1.6.0_38
export CLASSPATH=:/lib:/jre/lib:/demo/src/jdk1.6.0_38/lib:/demo/src/jdk1.6.0_38/jre/lib
export PATH=/demo/src/jdk1.6.0_38/bin:/demo/src/jdk1.6.0_38/jre/bin:/bin:/jre/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
export JRE_HOME=/demo/src/jdk1.6.0_38/jre
demo为jdk安装目录
然后
source /etc/profile
有可能是上面的命令有了2条