Hadoop [Lesson 2]: Install JDK (Java) on the virtual machine

1. Download JDK

download link

What I downloaded here is: jdk-8u221-linux-x64.tar.gz

Reason: After checking the official documentation of Hadoop, I found that there are more or less problems with the newer Java version, so I chose the more stable version of Java 1.8.

2. Transfer JDK to the virtual machine

Reference: [VMware] Xshell remote terminal to transfer files
Reference: XShell upload files to the virtual machine
Insert picture description here

3. Delete the original JDK of the virtual machine

(1) View the java version

# java -version

Insert picture description here
(2) Check the java installation location of centOS itself

# rpm -qa |  grep java

Insert picture description here
(3) Delete the file (rpm -e --nodeps package name)

# rpm -e --nodeps tzdata-java-2017b-1.el7.noarch python-javapackages-3.4.1-11.el7.noarch java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64 java-1.8.0-openjdk-headless-1.8.0.131-11.b12.el7.x86_64 javapackages-tools-3.4.1-11.el7.noarch

Insert picture description here
(4) Check that the Java version is empty at this time

# java -version

4. Install and configure JDK

(1) Unzip the JDK to the /usr/local/ folder

# tar -zxvf jdk-8u221-linux-x64.tar.gz -C /usr/local/java

Insert picture description here
Insert picture description here
(2) Configure environment variables
①Open the configuration file

# vi /etc/profile

② Modify the environment variable in the file to the directory where the JDK is located

export JAVA_HOME=/usr/local/java/jdk1.8.0_221
PATH=$PATH:$JAVA_HOME/bin

(3) Restart the configuration file

# source /etc/profile    

(4) Check that the version of Java has been updated

# java -version

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41315788/article/details/109264230