1.官網(wǎng)下載JDK
地址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html
選擇相應(yīng)的 .gz包下載
2. 解壓縮,放到指定目錄
(以jdk-7u60-linux-x64.gz為例)
創(chuàng)建目錄:
sudo mkdir /usr/lib/jvm
加壓縮到該目錄:
sudo tar -zxvf jdk-7u60-linux-x64.gz -C /usr/lib/jvm
3.修改環(huán)境變量:
sudo vim ~/.bashrc
文件的末尾追加下面內(nèi)容:
#set oracle jdk environment
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_60 ##這里要注意目錄要換成自己解壓的jdk 目錄
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
使環(huán)境變量馬上生效
source ~/.bashrc
4.測試jdk
java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)