CentOS 安装JDK
一、下载和解压JDK
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
二、设置环境变量
vi /etc/profile
在profile中添加如下内容:
#set java environment
JAVA_HOME=/home/java/jdk1.8.0_172
JRE_HOME=/home/java/jdk1.8.0_172/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
让配置文件生效:
source /etc/profile
三、验证
java -version
java version "1.8.0_172" Java(TM) SE Runtime Environment (build 1.8.0_172-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)