安装方式:rpm
下载JDK
进入安装包下载目录
cd /root/java
安装包下载
wget http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.rpm
安装JDK
安装包安装
rpm -ivh jdk-8u112-linux-x64.rpm
[root@iZuf61hly6h2nsymj5xb5fZ java]# rpm -ivh jdk-8u112-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk1.8.0_112 ########################################### [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
注:默认安装路径为:/usr/java
配置环境变量
编辑文件:/.bash_profile(不要修改/profile,该文件为系统配置文件)
vim ~/.bash_profile
在文件末尾输入以下几行:
...
export JAVA_HOME=/usr/java/jdk1.8.0_112
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
生效文件:~/.bash_profile
source /etc/profile
验证JDK安装
验证
java -version
[root@iZuf61hly6h2nsymj5xb5fZ environment]# java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
JDK1.8已经安装成功!