This article is reproduced in: Detailed steps to install jdk on Linux
Article directory
In the process of using linux, you always need to use jdk, and some linux systems come with openjdk, which is always not easy to use; this article takes centos7 as an example to install jdk1.8 version
1: Check whether the Linux system has its own jdk
1. Input: java -version to see if there is a jdk version
2. If there is an input: rpm -qa | grep java to detect jdk installation packages,
3. Then delete packages one by one, input: rpm -e --nodeps + Package name
4. Finally, again: rpm -qa | grep java to check whether the deletion is complete
2: Download jdk from the official website
Official website download link:
https://www.oracle.com/java/technologies/downloads/#java8
Because you need to log in to download jdk now, so here is what I downloaded in advance, and everyone mentions it:
link: https:/ /pan.baidu.com/s/1hr5CsGz8oms85B6tOmzRTA?pwd=gouu
3: Upload jdk installation to the linux server
I put it in the /opt directory here, and it is also recommended to put it in the /usr/local directory
4: Decompress jdk
Use the command to decompress: tar -xvf jdk-8u341-linux-x64.tar.gz
5: Configure environment variables
Use vim /etc/profile to enter the editing state, and add the following configuration
export JAVA_HOME=/opt/jdk1.8.0_341
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- 1
- 2
- 3
6: Reload the configuration, enter: source /etc/profile
7: Run the test
java -version
javac
jps
So far, the installation of jdk under linux has been completed