Linux安装JDK-CentOS7

下载安装包

在官网下载jdk 安装包:

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

解压

1
2
# 解压 并输出到 /usr/local
tar -zxvf jdk-8u91-linux-x64.tar.gz -C /usr/local

配置

编辑 /etc/profile

vim /etc/profile

1
2
3
4
JAVA_HOME=/usr/local/jdk1.8.0_91
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib
export JAVA_HOME PATH CLASSPATH

使配置生效:

source /etc/profile

验证

1
2
3
java
java -version
javac