Installation OpenJDK1.8:
1, check whether the current machine has a built-in JDK
rpm -qa |grep java
rpm -qa |grep jdk
rpm -qa |grep gcj
2, if not skip the installation steps, any uninstallation
rpm -qa | grep java | xargs rpm -e --nodeps
Step 3, yum update source
yum update -y
4, search yum package
yum list java-1.8*
5, the installation OpenJDK
yum install java-1.8.0-openjdk* -y
6. Verify that the installation was successful
java -version
返回信息如下,则说明安装成功:
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
7, other common questions:
If the command not found
command can not find it, then in addition to environmental issues, then you need to find the installation location OpenJDK will configure it to /etc/profile
file:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-3.b14.el6_9.x86_64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=$CLASSPATH:.:${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib
export PATH=${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:$PATH
After configuration is complete, click reload the file:
source /etc/profile
Installation OracleJDK1.8:
1, download OracleJDK1.8 & Upload
下载地址:
http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
➜ Linux Soft scp jdk-8u171-linux-x64.tar.gz [email protected]:/opt
[email protected]'s password:
jdk-8u171-linux-x64.tar.gz
2, extract to/usr/
[root@centos-linux ~]# cd /opt/
[root@centos-linux opt]# du -sm jdk-8u171-linux-x64.tar.gz
183 jdk-8u171-linux-x64.tar.gz
[root@centos-linux opt]# tar -xf jdk-8u171-linux-x64.tar.gz
[root@centos-linux opt]# mv jdk
jdk1.8.0_171/ jdk-8u171-linux-x64.tar.gz
[root@centos-linux opt]# mv jdk1.8.0_171 jdk
jdk1.8.0_171/ jdk-8u171-linux-x64.tar.gz
[root@centos-linux opt]# mv jdk1.8.0_171 jdk1.8
[root@centos-linux opt]# mv jdk1.8/ /usr/
[root@centos-linux opt]# cd /usr/
[root@centos-linux usr]# ls
bin etc games include jdk1.8 lib lib64 libexec local sbin share src tmp
[root@centos-linux usr]# cd jdk1.8/
[root@centos-linux jdk1.8]# pwd
/usr/jdk1.8
3, configure the environment variables
[root@centos-linux ~]# vim /etc/profile
# 在/etc/profile文件中大约第54行添加如下内容
# Java Env
export JAVA_HOME=/usr/jdk1.8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=$CLASSPATH:.:${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib
export PATH=${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:$PATH
[root@centos-linux ~]# source /etc/profile
4. Verify
[root@centos-linux ~]# java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)