Home > Article > Operation and Maintenance > 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:
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
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.gzThe 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/profilePress i to enter the editing modeInto 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:$PATHAfter 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/profileecho to check whether it takes effect.
echo $JAVA_HOME /usr/java/jdk1.8.0_211After 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:
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!