JDK installation and deployment steps in Linux environment

One, JDK download

1. Open the official website, the official website address: http://www.oracle.com/technetwork/java/javase/downloads

Remarks: The latest version of JDK is JAVA SE 15, but relatively speaking, JDK1.8 is used more and is more stable, so here we download JDK1.8 , or you can directly open the download page of JDK1.8. Download https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

2. According to the configuration of the Linux server to be installed, select the JDK installation package to download, here is a 64-bit jdk-8u271-linux-x64.tar.gz for illustration

3. Tick to agree to "Oracle Technology Network License Agreement" and click "Download"

4. You need to log in to the Oracle account to download the JDK, if you don’t have an Oracle account, you need to register first

Two, JDK installation

1. Open Xshell, connect to the Linux server remotely, then create a new java installation directory under the usr directory, and then ls to view the created java directory

cd /usr
mkdir java
ls

2. Click the Xftp file transfer button on Xshell, the transfer interface will open, and the tar.gz compressed file of the local JDK can be uploaded to the Linux test server

3. In the opened transfer interface, select the directory to be uploaded on the right side of the window, that is, the java folder directory we created, and then double-click the file to be uploaded in the left window, it will be automatically uploaded to the corresponding Linux directory

4. The upload is successful, you can see the newly uploaded JDK file in the right window

5. Enter the cd command into the newly created java directory, and then execute the ls view command. At this time, you will see that the successfully uploaded jdk-8u271-linux-x64.tar.gz compressed package already exists in the java directory.

cd java
ls

6. Enter the following command to decompress jdk to the current directory

tar -zxvf jdk-8u271-linux-x64.tar.gz

7. Execute the ls command to view the decompressed result

ls

8. Enter the following command to punch in the configuration file and configure the JDK environment variables

vim /etc/profile

9. Delete the original export configuration information and add the following content: Among them, JAVA_HOME is configured according to the actual directory

export JAVA_HOME=/usr/java/jdk1.8.0_271

export CLASSPATH=$JAVA_HOME/lib/

export PATH=$PATH:$JAVA_HOME/bin

export PATH JAVA_HOME CLASSPATH

Note:
When we edit or modify the content of the file, we need to save the edited content, and then exit the editing window. At this time, we can press "ESC" in the upper left corner of the keyboard, and then enter a "colon", that is, ":" (without double quotes), a colon will appear below, waiting for the input command, it is best to enter "wq" to save And exit

10. Execute the following command to restart the machine

sudo shutdown -r now

Or execute the command:

source /etc/profile

Note: If you restart the machine, you need to wait for a while before connecting to the Linux system

11. After the Linux server is started successfully, enter the following command to check whether the installation is successful. If you see the following JDK version information, it means the installation is successful

java -version

Guess you like

Origin blog.csdn.net/weixin_43184774/article/details/109580388