您的位置:首页 > 运维架构 > Linux

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

```


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: