centos7配置jdk环境

下载jdk包,地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

选择 jdk-8u231-linux-x64.tar.gz。上传至服务器对应目录,本次选择/usr/java

解压:

tar -zxvf jdk-8u231-linux-x64.tar.gz -C /usr/java/

添加环境变量 vi /etc/profile

export JAVA_HOME=/usr/java/jdk1.8.0_231
export CLASSPATH=.:${JAVA_HOME}/jre/lib/dt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

source /etc/profile 让配置生效

验证是否安装成功:
java \ javac \ java -version

[root@lxcos java]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

你可能感兴趣的:(centos7配置jdk环境)