Linux中jdk的安装
1.把压缩包上传到服务器/usr/local/jdk中
[root@VM_0_12_centos local]# ls
bin etc games include jdk lib lib64 libexec nginx nginx-1.10.2 qcloud redis redis-3.0.0 sbin share src tomcat yd.socket.server
[root@VM_0_12_centos local]# cd jdk/
[root@VM_0_12_centos jdk]# ls
jdk-8u151-linux-x64.tar.gz
2.解压jdk
[root@VM_0_12_centos jdk]# ls
jdk1.8.0_151 jdk-8u151-linux-x64.tar.gz[root@VM_0_12_centos jdk]# tar -zxvf jdk-8u151-linux-x64.tar.gz
jdk1.8.0_151
3.配置环境变量:vim /etc/profile(注所有的环境变量都在这设置)
[root@VM_0_12_centos etc]# ls profile
profile
编辑profile文件,
1,分割符用冒号 :
2.$变量名表示引用
3.export添加或修改系统变量
添加如下代码:
[root@VM_0_12_centos etc]# vim profile
#export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
JAVA_HOME=/usr/local/jdk/jdk1.8.0_151
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
4.解析文件(重启系统)
#source /etc/profile
5.验证配置是否生效 : java -version
[root@VM_0_12_centos etc]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)