CentOS 7 install jdk and configuration

1. Check the system version of your linux installation

method one:

cat /etc/redhat-release

Insert picture description here
Method Two:

cat /proc/version

Insert picture description here

The CentOS 7 I installed here uses yum to install java this time

2. View the jdk version that yum can install

yum list java*

Insert picture description here

3. Install jdk

This time choose to install java-1.8.0-openjdk-devel.x86_64

yum install java-1.8.0-openjdk-devel.x86_64   

Insert picture description here

4. Configure global variables

Open the configuration file and press i to enter the edit mode

vim /etc/profile

Copy the following code to the end of the file, Esc to exit the editing mode: wq Save and exit JAVA_HOME The installation location is subject to your actual installation location

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.x86_64
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

Enter source /etc/profile to make global variables take effect immediately

source /etc/profile

5. Check if the installation is successful

java -version

Insert picture description here

Guess you like

Origin blog.csdn.net/m0_52042041/article/details/113105338