centos安装JDK8

5 篇文章 0 订阅

概述

记录CentOS安装JDK8的过程。


软件环境

CentOS:6.5,x86-64位版本

JDK: 8.0,x86-64位版本,rpm格式


安装

首先切换到root:

```

su - root

```

然后安装jdk:

```

rpm -ivh jdk-8-linux-x64.rpm


Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
 rt.jar...
Error: Could not open input file: /usr/java/jdk1.8.0/jre/lib/rt.pack
Error: unpack could not create JAR file:

 /usr/java/jdk1.8.0/jre/lib/rt.jar

Please refer to the Troubleshooting section of the Installation Instructions
on the download page.
 jsse.jar...
Error: Could not open input file: /usr/java/jdk1.8.0/jre/lib/jsse.pack
Error: unpack could not create JAR file:

 /usr/java/jdk1.8.0/jre/lib/jsse.jar

Please refer to the Troubleshooting section of the Installation Instructions
on the download page.
 charsets.jar...
Error: Could not open input file: /usr/java/jdk1.8.0/jre/lib/charsets.pack
Error: unpack could not create JAR file:

 /usr/java/jdk1.8.0/jre/lib/charsets.jar

Please refer to the Troubleshooting section of the Installation Instructions
on the download page.
 tools.jar...
Error: Could not open input file: /usr/java/jdk1.8.0/lib/tools.pack
Error: unpack could not create JAR file:

 /usr/java/jdk1.8.0/lib/tools.jar

Please refer to the Troubleshooting section of the Installation Instructions
on the download page.
 localedata.jar...
Error: Could not open input file: /usr/java/jdk1.8.0/jre/lib/ext/localedata.pack
Error: unpack could not create JAR file:

 /usr/java/jdk1.8.0/jre/lib/ext/localedata.jar

Please refer to the Troubleshooting section of the Installation Instructions
on the download page.
 jfxrt.jar...
Error: Could not open input file: /usr/java/jdk1.8.0/jre/lib/ext/jfxrt.pack
Error: unpack could not create JAR file:

 /usr/java/jdk1.8.0/jre/lib/ext/jfxrt.jar

Please refer to the Troubleshooting section of the Installation Instructions
on the download page.

```

出现上面的错误是因为系统中已经有JDK的其他版本,使用`rpm -qa | grep jdk`查询存在的jdk,并用`rpm -e`命令移除。之后再次执行安装,顺利通过

```

Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
 rt.jar...
 jsse.jar...
 charsets.jar...
 tools.jar...
 localedata.jar...
 jfxrt.jar...

```


配置环境变量

编辑环境变量,配置path和classpath。vi /etc/profile,增加下面配置:

```

export JAVA_HOME=/usr/java/jdk1.8.0/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

```

保存退出后,执行`source /etc/profile`使变更生效。


检测安装的是否正确,在shell中执行`java -version`和`javac -version`,如果shell显示如下的信息,表示安装成功:

```

[root@localhost Downloads]# java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
[root@localhost Downloads]# javac -version
javac 1.8.0

```




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值