·用文本编辑器打开/etc/profile
·在profile文件末尾加入:
export JAVA_HOME=/usr/lib/jdk1.6.0_45
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
sudo source /etc/profile
sudo update-alternatives --install /usr/bin/java java /usr/lib/java1.6.0_45/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/java1.6.0_45/bin/javac 300
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/java1.6.0_45/bin/javah 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/java1.6.0_45/bin/jar 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/java1.6.0_45/bin/javap 300
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/java1.6.0_45/bin/javaws 300