centos7 download jdk

jdk Download: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

 
Download jdk-8u152-linux-x64.rpm or jdk-8u152-linux-x64.tar.gz (selected according to their corresponding packet system bits)
 
Figure:
 
Installation jdk
 
Since I installed CentOS7.4 system comes with jdk1.8, so in order to demonstrate how to install jdk, I need to uninstall the system comes with jdk
 
View the current system jdk version: java -version
Java list matches installed packages: yum list installed | grep java
 
 
 
Uninstall jdk installation:
 
yum -y remove java-1.7.0-openjdk*
 
yum -y remove java-1.8.0-openjdk*
 
When the results appeared finished! , It means unloading success.
Installation jdk:
 
  1. New java folder in / usr / in, mkdir java
  2. The use Xftp downloaded jdk-8u211-linux-x64.tar.gz uploaded to the / usr / java, we need to chmod 777 / usr / java
3, the decompression package: tar -zxvf jdk-8u211-linux-x64.tar.gz
 
At this point the java -version command can not be used
 
 
Configuration environment variable:
 
Use vim / etc / profile edit profile file input: vim / etc / profile
Press i to enter edit mode
 
Append the following to the file inside:
 
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
Edit When finished, press Esc enter: wq Quit
 
Save and exit, then environmental variables have to perform
source /etc/profile
echo to see if the entry into force
echo $JAVA_HOME
/usr/java/jdk1.8.0_211
After set the environment variable, enter: java, javac, java -version be able to access content that is normal

Guess you like

Origin www.cnblogs.com/mengmengxidi/p/11330157.html