Java环境变量配置(CentOS)
1 下载安装JDK
下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
选择Linux x64 Compressed Archive对应的tar.gz文件。
解压至安装目录
创建目录
mkdir /opt/jdk1.8
解压
tar -zxvf jdk-8u171-linux-x64.tar.gz -C /opt/java1.8/
2 配置环境变量
vim /etc/profile
修改此文件
export JAVA_HOME=/opt/jdk1.8 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
配置生效
source /etc/profile
3 检查是否安装成功
[superadmin@ycyzharry ~]$ java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)