Reprint: Install JDK under Linux

This article is reproduced in: Detailed steps to install jdk on Linux



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
insert image description here
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
insert image description here

2: Download jdk from the official website

Official website download link:
https://www.oracle.com/java/technologies/downloads/#java8
insert image description here
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
insert image description here

4: Decompress jdk

Use the command to decompress: tar -xvf jdk-8u341-linux-x64.tar.gz

insert image description here

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

insert image description here

6: Reload the configuration, enter: source /etc/profile

insert image description here

7: Run the test

java -version
insert image description here
javac
insert image description here
jps
insert image description here
So far, the installation of jdk under linux has been completed

Guess you like

Origin blog.csdn.net/qq_36256590/article/details/132182864