Install JDK1.8 in Linux

                            Linux  (Centos)中安装JDK1.8

First open the JDK official website. The download URL for JDK1.8 is: https://www.oracle.com/cn/java/technologies/downloads/#java8-windows

  1. The first step is to download jdk1.8, create a download folder in Linux, put it in the compressed package and decompress it.

  2. Create a java (or jdk depending on personal preference) folder in /usr/local/

  3. Move it under this file through the command mv /download/xxx (decompressed file name) <space> /usr/local/java

  4. Edit profile file

vim /etc/profile

Click "i" to enter editing mode and write at the bottom

export JAVA_HOME=/usr/local/java/jdk1.8.0_311
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}  

As shown below:
Insert image description here
5. After that, click esc and enter <:wq> to exit the edit. Finally, reload the configuration in source /etc/profile.

source /etc/profile

6. Enter java -version and javac to check whether the installation is successful.
Insert image description here

Guess you like

Origin blog.csdn.net/qq_37120477/article/details/131449747