Java applications and some open source components depend on the JDK, so in many cases, you need to install the JDK on the Linux system. There are many ways to install the JDK. Both yum installation and manual installation are possible. For the installation steps of yum, please refer to "How to Install JDK in Linux yum ". This article briefly summarizes the steps to manually install the JDK.
1. Download the JDK installation package and upload it to the specified path on the server
Go to the official website https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to download the JDK1.8 tar package, here is jdk-8u281-linux-x64.tar, Upload the jdk-8u281-linux-x64.tar file to the server /usr/local path (other paths are also possible).
[root@vmtest local]# pwd
/usr/local
[root@vmtest local]# ls
jdk-8u281-linux-x64.tar
Only the JDK installation package is shown here, and other files are omitted.
Two, unzip the JDK
[root@vmtest local]# tar -xvf jdk-8u281-linux-x64.tar
[root@vmtest local]# ls
jdk1.8.0_281 jdk-8u281-linux-x64.tar
Three, configure environment variables
View the path of JDK1.8
[root@vmtest local]# cd jdk1.8.0_281/
[root@vmtest jdk1.8.0_281]# ll
total 25804
drwxr-xr-x 2 10143 10143 4096 Dec 9 20:47 bin
-r--r--r-- 1 10143 10143 3244 Dec 9 20:47 COPYRIGHT
drwxr-xr-x 3 10143 10143 125 Dec 9 20:47 include
-rw-r--r-- 1 10143 10143 5226870 Dec 9 18:15 javafx-src.zip
-rw-r--r-- 1 10143 10143 195 Dec 9 20:47 jmc.txt
drwxr-xr-x 6 10143 10143 4096 Dec 9 20:47 jre
drwxr-xr-x 4 10143 10143 29 Dec 9 20:47 legal
drwxr-xr-x 4 10143 10143 4096 Dec 9 20:47 lib
-r--r--r-- 1 10143 10143 44 Dec 9 20:47 LICENSE
drwxr-xr-x 4 10143 10143 44 Dec 9 20:47 man
-r--r--r-- 1 10143 10143 159 Dec 9 20:47 README.html
-rw-r--r-- 1 10143 10143 424 Dec 9 20:47 release
-rw-r--r-- 1 10143 10143 21147701 Dec 9 20:47 src.zip
-rw-r--r-- 1 10143 10143 190 Dec 9 18:15 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r-- 1 10143 10143 190 Dec 9 20:47 THIRDPARTYLICENSEREADME.txt
[root@vmtest jdk1.8.0_281]# pwd
/usr/local/jdk1.8.0_281
Edit environment variables, command: vim /etc/profile. Append the following at the end of the file:
export JAVA_HOME=/usr/local/jdk1.8.0_281
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
Four, refresh environment variables
[root@vmtest jdk1.8.0_281]# source /etc/profile
-bash: HISTSIZE: readonly variable
-bash: TMOUT: readonly variable
-bash: HISTSIZE: readonly variable
-bash: HISTFILESIZE: readonly variable
Five, check whether the installation is successful
To query the JDK version, the command is as follows:
[root@vmtest jdk1.8.0_281]# java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
[root@vmtest jdk1.8.0_281]#
The result shows that the manual installation of the JDK has been successful.