直接下載jdk壓縮包方式安裝
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 使環(huán)境變量馬上生效 source ~/.bashrc 4.設(shè)置系統(tǒng)默認(rèn)jdk 版本sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_60/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_60/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7.0_60/bin/jar 300
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.7.0_60/bin/javah 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0_60/bin/javap 300
然后執(zhí)行: sudo update-alternatives --config java
若是初次安裝jdk,會(huì)有下面的提示 There is only one alternative in link group java (providing /usr/bin/java): 否者,選擇合適的jdk 5.測(cè)試jdkjava -version Java(TM) SE Runtime Environment (build 1.7.0_60-b19) jdk 安裝成功 |
|