1.将下载好的jdk安装包上传至服务器
2.解压到指定目录
tar -zxvf /opt/software/jdk-7u80-linux-x64.tar.gz -C /opt/java/
3.设置环境变量
vim /etc/profile
在文本最后加入以下代码
export JAVA_HOME=/opt/java/jdk1.7.0_80/
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
保存退出。
4.让刚才的配置生效
source /etc/profile
5.验证刚才的配置
java -version
也可以这样,echo $JAVA_HOME