JDK7 install

转:http://blog.csdn.net/luxiaoyu_sdc/article/details/7303155
ubuntu 安装jdk7,现在来总结一下:
第一步:下载jdk-7-linux-i586.tar.gz
直接在ORACLE的官网中下载就可以:
http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html
PS:要注意系统版本的选择,32位 还是 64位,uname -a 命令即可知道答案。
第二步:解压安装
master@master-VirtualBox:~$ sudo mkdir /usr/local/jvm
master@master-VirtualBox:~$ sudo cp /mnt/shared/jdk-7u79-linux-x64.tar.gz /usr/local/jvm/
master@master-VirtualBox:~$ cd /usr/local/jvm/
master@master-VirtualBox:/usr/local/jvm$ ls
jdk-7u79-linux-x64.tar.gz
master@master-VirtualBox:/usr/local/jvm$ sudo tar -xzf jdk-7u79-linux-x64.tar.gz
master@master-VirtualBox:/usr/local/jvm$


第三步:修改环境变量
sudo gedit ~/.bashrc
export JAVA_HOME=/usr/local/jvm/jdk1.7.0_79

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH
加到末尾
保存退出
source ~/.bashrc
第四步:配置默认JDK版本
master@master-VirtualBox:/usr/local/jvm$ sudo update-alternatives --install /usr/bin/java java /usr/local/jvm/jdk1.7.0_79/bin/java 300
update-alternatives: using /usr/local/jvm/jdk1.7.0_79/bin/java to provide /usr/bin/java (java) in auto mode
master@master-VirtualBox:/usr/local/jvm$ sudo update-alternatives --install /usr/bin/javac javac /usr/local/jvm/jdk1.7.0_79/bin/javac 300
update-alternatives: using /usr/local/jvm/jdk1.7.0_79/bin/javac to provide /usr/bin/javac (javac) in auto mode
master@master-VirtualBox:/usr/local/jvm$ sudo update-alternatives --install /usr/bin/jar jar /usr/local/jvm/jdk1.7.0_79/bin/jar 300
update-alternatives: using /usr/local/jvm/jdk1.7.0_79/bin/jar to provide /usr/bin/jar (jar) in auto mode
master@master-VirtualBox:/usr/local/jvm$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

检查
sudo update-alternatives --config java 
第五步:查看java版本号
命令行:
java -version
系统会列出
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode)

你可能感兴趣的:(Install)