CentOS - Install JDK offline

1. Upload the JDK package

The JDK package can be downloaded from the official website: Java Downloads | Oracle
uploads the JDK package to the specified path on the server, such as: /home/tool

2. Unzip JDK

tar -zxvf jdk-8u251-linux-x64.tar.gz
# 修改文件名
mv jdk1.8.0_251 jdk

3. Configure JDK environment variables

edit global variables

vim /etc/profile

Paste the following in the last line of text:

#java environment
export JAVA_HOME=/home/tool/jdk
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

 Note: JAVA_HOME=/home/tool/jdk is configured according to the actual directory

Set environment variables to take effect

source /etc/profile

4. Check whether the installation is successful

java -version

If the version information is displayed normally, it is successful

Guess you like

Origin blog.csdn.net/qq_34272760/article/details/131683065