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
-
The first step is to download jdk1.8, create a download folder in Linux, put it in the compressed package and decompress it.
-
Create a java (or jdk depending on personal preference) folder in /usr/local/
-
Move it under this file through the command mv /download/xxx (decompressed file name) <space> /usr/local/java
-
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:
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.