Ubuntu 12.10 安装 JDK 7u15官方版
1. 打开官网下载Java安装文件
jdk-7u15-linux-x64.tar.gz
2.打开终端,根据个人习惯建立目录
sudo mkdir /usr/local/development
3.将下载的文件移动到这个文件夹下面并进行解压。使用如下命令:
sudo mv jdk-7u15-linux-x64.tar.gz /usr/local/development
sudo tar -zxvf jdk-7u15-linux-x64.tar.gz
4.修改环境变量
sudo gedit /etc/environment
源文件的内容是这样的:
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.配置默认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.测试:
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:~$
关键词:Ubuntu,JDK
阅读本文后您有什么感想? 已有 人给出评价!
- 0
- 2
- 0
- 0
- 0
- 6