linux download and install jdk

1. Download jdk from the official website

The following is the jdk download address, just click it

Java Downloads | Oracle

 Just download the jdk you need, it is recommended to download jdk8

2. Transfer jdk to linux server

2.1 First create a folder in linux and enter 

mkdir /opt

cd /opt

2.2 Use xftp to upload jdk to linux

 2.3 Decompress jdk

tar -zxvf your jdk name

3. Configure environment variables

vi /etc/profile

After inputting and pressing Enter, add the following information at the end of the file:

Note: JAVA_HOME=/usr/local/jdk/jdk1.8.0_181 in the first line is the actual decompression directory of your own jdk on the right side of the equal sign. If it is not the directory, you need to change it to your own actual directory, and the others remain unchanged.

export JAVA_HOME=/opt/jdk1.8.0_202
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin

 or as follows

export JAVA_HOME=/opt/jdk1.8.0_202
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 

After editing, save and exit, then enter the following command to refresh the environment configuration to take effect:

​source /etc/profile

4. Whether the test is successful

java -version 

 

The version description appears successfully 

Guess you like

Origin blog.csdn.net/wang20010104/article/details/127110654