Linux通过安装包方式安装Java1.7环境

1.官网下载JDK   

    地址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html

  选择相应的 .gz包下载

2. 解压缩,放到指定目录(以jdk-7u80-linux-x64.gz为例)

  创建目录:

sudo mkdir /usr/lib/jvm

 加压缩到该目录:

sudo tar -zxvf jdk-7u80-linux-x64.gz -C /usr/lib/jvm

3. 修改环节变量

sudo vim ~/.bashrc

 文件的末尾追加下面内容:

#set oracle jdk environment

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_80

export JRE_HOME=${JAVA_HOME}/jre 

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

export PATH=${JAVA_HOME}/bin:$PATH

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_80/bin/java 300 

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_80/bin/javac 300 

sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7.0_80/bin/jar 300 

sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.7.0_80/bin/javah 300 

sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0_80/bin/javap 300

切换环境:

然后执行:

sudo update-alternatives --config java

验证:

java -version

你可能感兴趣的:(Linux通过安装包方式安装Java1.7环境)