系统环境:centos-6.5
安装方式:rpm安装
软件:jdk-8u20-linux-x64.rpm
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
检验当前版本:
[[email protected] ~]# java -version
列出所有Java相关的软件信息:
[[email protected] ~]# rpm -qa | grep java
卸载OpenJDK:
[[email protected] ~]# rpm -e --nodeps xxx(xxx为之前搜出的Java相关的的软件)
安装JDK:
[[email protected] JDK]# rpm -ivh jdk-8u20-linux-x64.rpm
JDK默认安装在/usr/java中。
验证安装,查看信息是否正常:
[[email protected] bin]# java
[[email protected] bin]# javac
[[email protected] bin]# java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
配置环境变量:
vi + /etc/profile
向文件里面追加以下内容:
JAVA_HOME=/usr/java/jdk1.8.0_20
JRE_HOME=/usr/java/jdk1.8.0_20/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
使修改生效
[[email protected] ~]# source /etc/profile //使修改立即生效
[[email protected] ~]# echo $PATH //查看PATH值