Centos7.x installs jdk1.8 and configures the Java environment.

1. Open the url to download jdk1.8

click to download
Insert image description here

2.Installation

2.1 Create directory

mkdir /usr/local/java/

2.2 Unzip to the installation directory

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

3. Environment variable configuration

3.1 Open the file

vim /etc/profile

3.2 Add at the end

export JAVA_HOME=/usr/local/java/jdk1.8.0_171
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

3.3 Make environment variables effective

source /etc/profile

3.4 Add soft connection

ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java

4. Check whether the installation is successful

java -version

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_45500785/article/details/131826025