jdk-7u15-linux-x64.tar.gz
2.打開終端,根據(jù)個(gè)人習(xí)慣建立目錄
sudo mkdir /usr/local/development
3.將下載的文件移動(dòng)到這個(gè)文件夾下面并進(jìn)行解壓。使用如下命令:
sudo mv jdk-7u15-linux-x64.tar.gz /usr/local/developmentsudo tar -zxvf jdk-7u15-linux-x64.tar.gz
4.修改環(huán)境變量
sudo gedit /etc/environment源文件的內(nèi)容是這樣的:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
修改為:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:${JAVA_HOME}/bin"
JAVA_HOME=/usr/local/development/jdk1.7.0_15
jre_HOME=${JAVA_HOME}/jre
CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib"
5.重新加載bashrc
source ~/.bashrc
6.配置默認(rèn)JDK
sudo update-alternatives --install /usr/bin/java java /usr/local/development/jdk1.7.0_15/bin/java 300
sudo update-alternatives --install /usr/bin/javap javap /usr/local/development/jdk1.7.0_15/bin/javap 300
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/local/development/jdk1.7.0_15/bin/javadoc 300
7.測(cè)試:
java -version如下顯示表示配置成功:
arlen@Arlen-TOP2:~$ java -version
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
arlen@Arlen-TOP2:~$