Installing JDK 8 on CentOS Linux

Preparation

Server: CentOS Linux release 7.9.2009 (Core)

JDK: jdk-8u301-linux-x64.tar.gz

JDK 8 download link:https://www.oracle.com/java/technologies/downloads/#java8

Installation

Connect to the server using Xshell.

Upload to the server, you can use the command

# rz upload, -y to overwrite files rz -y

If prompted that the command ‘rz’ is not found, install it manually

# rz is a file transfer tool based on the zmodem protocol, part of the lrzsz package. Use rz to upload files, sz to download files. yum install -y lrzsz

Alternatively, you can use Xftp to upload files.Installing JDK 8 on CentOS LinuxAfter uploading, extract the files

# Extract jdk to /usr/local directory, -C specifies the extraction directory tar -zxvf jdk-8u301-linux-x64.tar.gz -C /usr/local/

You can check the extraction directoryInstalling JDK 8 on CentOS LinuxConfigure environment variablesAs we know, when installing JDK on Windows, we need to configure environment variables for easy use of Java; similarly, Linux also requires configuration.Edit the /etc/profile file

vi /etc/profile # or use vim vim /etc/profile

Press thei key on the keyboard, and add the following two lines at the end

export JAVA_HOME=/usr/local/jdk1.8.0_301 export PATH=$JAVA_HOME/bin:$PATH

The result should look like this:Installing JDK 8 on CentOS LinuxAfter entering, press theEsc key, type :wq (to save the edited content), then press EnterInstalling JDK 8 on CentOS LinuxMake the configuration effective

source /etc/profile

Verification

java -version

If the output is as follows, it means the installation was successful

Installing JDK 8 on CentOS LinuxInstalling JDK 8 on CentOS LinuxInstalling JDK 8 on CentOS Linux

Leave a Comment