在安装之前先检查一下自己的系统,rpm -qa|grep jdk 键入终端,查看安装了多少jdk?
如果没有直接跳到下载jdk那一步骤,如果有比如果我的
java-1.7.0-openjdk-devel-1.7.0.141-2.6.10.1.el6_9.x86_64
java-1.7.0-openjdk-javadoc-1.7.0.141-2.6.10.1.el6_9.noarch
java-1.7.0-openjdk-1.7.0.141-2.6.10.1.el6_9.x86_64
java-1.7.0-openjdk-demo-1.7.0.141-2.6.10.1.el6_9.x86_64
java-1.7.0-openjdk-src-1.7.0.141-2.6.10.1.el6_9.x86_64
建议先删除
yum remove xxx
例如
yum remove java-1.7.0-openjdk-devel-1.7.0.141-2.6.10.1.el6_9.x86_64
然后安装jdk
1)下载安装jdk
JDK下载官网
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载后上传到服务器(目录可自定义)
# rpm -ivh jdk-8u131-linux-x64.rpm
Preparing...???????????????########################################### [100%]
1:jdk1.8.0_113??????????########################################### [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
# java -version
java version"1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
# vim
/etc/profile添加jdk环境变量
exportJAVA_HOME=/usr/java/jdk1.8.0_131
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