CentOS7安装JDK8
检查是否已装有其他版本的JDK,执行命令:rpm -qa | grep java,得到结果如下: 如上所示,当前已有openjdk的1.7和1.8版本,我们需要将其卸载; 3.下载jdk-8u172-linux-x64.tar.gz,官网地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 7. 使配置立即生效:source /etc/profile 至此,CentOS7安装JDK8成功;
[[email protected] work]# rpm -qa | grep javatzdata-java-2017c-1.el7.noarchjava-1.7.0-openjdk-headless-1.7.0.151-2.6.11.1.el7_4.x86_64
java-1.7.0-openjdk-1.7.0.151-2.6.11.1.el7_4.x86_64
java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64
java-1.8.0-openjdk-headless-1.8.0.151-1.b12.el7_4.x86_64
python-javapackages-3.4.1-11.el7.noarchjavapackages-tools-3.4.1-11.el7.noarch12345678
2. 卸载上一步发现的已装的jdk,执行以下命令:rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.151-2.6.11.1.el7_4.x86_64 java-1.7.0-openjdk-1.7.0.151-2.6.11.1.el7_4.x86_64 java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64 java-1.8.0-openjdk-headless-1.8.0.151-1.b12.el7_4.x86_6412345
4. 解压:tar -zxvf jdk-8u172-linux-x64.tar.gz
5. 将解压后的文件夹移动到/usr/local目录下:mv jdk1.8.0_172 /usr/local/
6. 打开文件/etc/profile,添加以下内容:export JAVA_HOME=/usr/local/jdk1.8.0_172
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib/dt.JAVA_HOME/lib/tools.jar:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}1234
8. 查看当前java版本信息:java -version,可以看到如下基本内容:[[email protected] ~]# java -version
java version "1.8.0_161"Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)1234
版权声明:欢迎转载,请注明出处,谢谢。 https://blog.csdn.net/boling_cavalry/article/details/79840049
原文地址:http://blog.51cto.com/juey2017/2123542