系统环境:centos7安装方式:rpm安装软件:jdk-8u25-linux-x64.rpm下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html检验系统原版本[root@zck ~]# java -versionjava version "1.7.0_"OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)进一步查看JDK信息:[root@localhost ~]# rpm -qa | grep javajavapackages-tools-3.4.1-6.el7_0.noarchtzdata-java-2014i-1.el7.noarchjava-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64python-javapackages-3.4.1-6.el7_0.noarch卸载OpenJDK,执行以下操作:[root@localhost ~]# rpm -e --nodeps tzdata-java-2014i-1.el7.noarch[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64安装JDK上传新的jdk-8u25-linux-x64.rpm软件到/usr/local/执行以下操作:[root@zck local]# rpm -ivh jdk-8u25-linux-x64.rpmJDK默认安装在/usr/java中。验证安装执行以下操作,查看信息是否正常:[root@localhost ~]# java[root@localhost ~]# javac[root@localhost ~]# java -versionjava version "1.8.0_25"Java(TM) SE Runtime Environment (build 1.8.0_25-b17)Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)配置环境变量我的机器安装完jdk-7-linux-x64.rpm后不用配置环境变量也可以正常执行javac、java –version操作,因此我没有进行JDK环境变量的配置。但是为了以后的不适之需,这里还是记录一下怎么进行配置,操作如下:修改系统环境变量文件vi + /etc/profile向文件里面追加以下内容:JAVA_HOME=/usr/java/jdk1.8.0_25JRE_HOME=/usr/java/jdk1.8.0_25/jrePATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libexport JAVA_HOME JRE_HOME PATH CLASSPATH使修改生效[root@localhost ~]# source /etc/profile //使修改立即生效[root@localhost ~]# echo $PATH //查看PATH值查看系统环境状态[root@localhost ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_25/bin:/usr/java/jdk1.8.0_25/jre/bin
`````````````````````````````````````````````````````````````
我们这里安装1.7版本[root@localhost ~]# yum install java-1.7.0-openjdk
安装完之后,默认的安装目录是在: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
3.设置环境变量[root@localhost ~]# vi /etc/profile
添加如下内容:#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效:[root@localhost java]# source /etc/profile