首先是下载jdk1.8,官网链接:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
举个栗子,我下载到的jdk1.8版本的文件名称是:jdk-8u241-linux-x64.tar.gz
1.去 /usr/local/下面建一个“java”文件夹
cd /usr/local/
mkdir java
2.安装到指定目录下
tar -zxvf jdk-8u241-linux-x64.tar.gz -C /usr/local/java/
3.jdk的路径: /usr/local/java/jdk1.8.0_241
4.添加路径到系统
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_241
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
5.检验安装是否成功:javac
6.检查环境变量:echo $JAVA_HOME
网友评论