1 Java 8 下载地址
http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html
2 以root用户登录将下载的jdk-8u92-linux-x64.tar.gz文件放到/temp目录下,使用如下命令解压
tar zxvf jdk-8u92-linux-x64.tar.gz
3 将解压后的jdk1.8.0_92复制到/opt下,命令如下:
[email protected]:~# mkdir /temp
[email protected]:~# cd /temp
[email protected]:/temp# tar zxvf jdk-8u92-linux-x64.tar.gz
[email protected]:/temp# cd /opt
[email protected]:/opt# mv /temp/jdk1.8.0_92/ .
[email protected]:/opt# ls -l
总用量 4
drwxr-xr-x 8 uucp 143 4096 4月 1 12:20 jdk1.8.0_92
4 在/bin目录下创建java软链接
[email protected]:/opt# cd /bin
[email protected]:/bin# ln -s /opt/jdk1.8.0_92/bin/java java
验证软件接的正确性
[email protected]:/bin# java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
5 设置Java环境
[email protected]:/bin# gedit /etc/profile export JAVA_HOME=/opt/java1.8.0_92 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH={JAVA_HOME}/bin:$PATH [email protected]:/bin# source /etc/profile [email protected]:/bin# echo $JAVA_HOME /opt/java1.8.0_92
6 切换到其它用户验证
[email protected]:~$ echo $JAVA_HOME /opt/java1.8.0_92 [email protected]:~$ java -version java version "1.8.0_92" Java(TM) SE Runtime Environment (build 1.8.0_92-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
时间: 2024-10-17 17:18:45