#下載&解壓java
mkdir /opt/java/ cd /opt/java/ wget http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz tar xvf jdk-7u79-linux-x64.tar.gz
1.經過軟鏈接linux
ln -s /opt/java/jdk1.7.0_79/bin/java /usr/bin/java ln -s /opt/java/jdk1.7.0_79/bin/javac /usr/bin/javac --去掉軟鏈接 rm /usr/bin/java
2.經過配置 /etc/profile 對全部用戶有效shell
vi /etc/profile JAVA_HOME=/opt/java/jdk1.7.0_79/ PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME export PATH export CLASSPATH
3.修改~/.bashrc文件(該方法修改後只對當前用戶有效,對該用戶的全部shell都有效)bash
vi ~/.bashrc JAVA_HOME=/opt/java/jdk1.7.0_79/ PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME export PATH export CLASSPATH