centos安装JDK8
2014-04-05 19:17
531 查看
概述
记录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
```
相关文章推荐
- CentOS 7 安装JDK8、Tomcat8并设置tomcat服务开机自启
- CentOS7.64位下安装jdk8
- 在CentOS 7中安装与配置JDK8
- CentOS6.7+jdk8+hadoop2.7.1+hbase1.1.3+hive2.0.0+scala2.11.7+spark1.6集群安装!!!
- 基础2:CentOS7 安装JDK8和Tomcat9
- Centos7 安装 JDK8
- centos安装jdk8,安装IntelliJ Idea
- centos6.5 安装jdk8
- Centos7 JDK8安装配置
- Centos7 JDK8安装配置
- CentOS 6.5 x64 安装jdk8
- centos下安装JDK8的方法
- CentOS 7下JDK8的详细安装步骤
- CentOS 7 jdk8安装说明
- CentOS安装JDK8
- CentOS6.5安装jdk8
- 阿里云 CentOs7.4 yum 安装 jdk8
- 卸载CentOS7-x64自带的OpenJDK并安装Sun的JDK8的方法
- 在CentOS 7中安装与配置JDK8
- 删除 CentOS 自带的 JDK7,重新安装 JDK8 的方法