Ubuntu 12.10 安裝 JDK 7u15官方版
1. 打開(kāi)官網(wǎng)下載Java安裝文件
jdk-7u15-linux-x64.tar.gz
2.打開(kāi)終端,根據(jù)個(gè)人習(xí)慣建立目錄
sudo mkdir /usr/local/development
3.將下載的文件移動(dòng)到這個(gè)文件夾下面并進(jìn)行解壓。使用如下命令:
sudo mv jdk-7u15-linux-x64.tar.gz /usr/local/development
sudo 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/javac javac /usr/local/development/jdk1.7.0_15/bin/javac 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:~$
關(guān)鍵詞:Ubuntu,JDK
閱讀本文后您有什么感想? 已有 人給出評(píng)價(jià)!
- 0
- 2
- 0
- 0
- 0
- 6