时间:2020-10-20 15:21:14 | 栏目:Linux | 点击:次
手动解压JDK的压缩包,然后设置环境变量
1.在/usr/目录下创建java目录
[root@localhost ~]# mkdir/usr/java [root@localhost ~]# cd /usr/java
2.下载,然后解压
[root@localhost java]# curl -O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz [root@localhost java]# tar -zxvf jdk-7u79-linux-x64.tar.gz
3.设置环境变量
[root@localhost java]# vi /etc/profile
添加如下内容:
#set java environment JAVA_HOME=/usr/java/jdk1.7.0_79 JRE_HOME=/usr/java/jdk1.7.0_79/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效:
[root@localhost java]# source /etc/profile
4.验证
[root@localhost java]# 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)