1.源码包准备
从Oracle官网下载jdk-8u181-linux-x64.tar.gz
2.解压缩
将jdk安装到opt下首先创建java文件夹,然后将源码包放到java文件夹下,执行解压缩
1 | sudo cd /opt/ |
解压缩完成后是ls查看发现会多出jdk1.8.0_181
的文件夹
3.配置环境变量
1 | sudo vi /etc/profile |
在最后面加上1
2
3
4export JAVA_HOME=/opt/java/jdk1.8.0_181
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
执行source profile
时生效
4.检查
输入java -version检查是否安装成功1
java -version