Home  >  Article  >  Operation and Maintenance  >  How to download jdk in centos system

How to download jdk in centos system

王林
王林Original
2020-03-21 11:24:142123browse

How to download jdk in centos system

Download jdk-8u152-linux-x64.rpm or jdk-8u152-linux-x64.tar.gz (select the corresponding package according to the number of bits of your system)

As shown in the picture:

How to download jdk in centos system

The steps to install jdk are as follows:

Because the CentOS7.4 system I installed comes with jdk1.8, so in order to demonstrate how To install jdk, I need to uninstall the jdk that comes with the system first

Check the current system jdk version:

java -version

How to download jdk in centos system

List the software packages that match the installed java :

yum list installed | grep java

(Recommended tutorial: centos usage tutorial)

1. Uninstall the installed jdk:

yum -y remove java-1.7.0-openjdk*
yum -y remove java-1.8.0-openjdk*

2. Install jdk

Create a new java folder in /usr/, mkdir java uses Xftp to upload the downloaded jdk-8u211-linux-x64.tar.gz to /usr/java, chmod 777 /usr/java

# is required. ##3. Unzip the package:

tar -zxvf jdk-8u211-linux-x64.tar.gz

The java -version command cannot be used at this time.

4. Configure environment variables:

Use vim /etc/profile to edit the profile file and enter:

vim /etc/profile

Press i to enter the editing mode

Into the file Append the following content:

export JAVA_HOME=/usr/java/jdk1.8.0_211
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

After editing, press Esc and enter: wq to exit

Save and exit. At this time, you need to execute the command to take effect of the environment variable:

source /etc/profile

echo to check whether it takes effect.

echo $JAVA_HOME
/usr/java/jdk1.8.0_211

After the environment variables are set, it is normal to be able to access the content by typing: java, javac, java -version.

Recommended related video tutorials:

linux video tutorial

The above is the detailed content of How to download jdk in centos system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn