安装Java
官网:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载jdk-8u144-linux-x64.tar.gz,如果下载rpm包则不需要配置环境变量
tar xzvf jdk-8u144-linux-x64.tar.gz
mkdir /usr/local/java
mv jdk1.8.0_144/ /usr/local/java/jdk
配置Java环境变量
vim /etc/profile 添加以下三行内容
export JAVA_HOME=/usr/java/jdk
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
[[email protected] ~]# source /etc/profile
测试环境变量配置成功:
[[email protected] ~]# java -version
java -version
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)