这里我们拿jdk8来作为例子
下载地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
mkdir /usr/local/java
cd /usr/local/java
tar -zxvf jdk-8u151-linux-x64.tar.gz
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk8
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JRE_HOME=$JAVA_HOME/jre
source /etc/profile
java -version
安装包直接去apache官网下载:https://maven.apache.org/download.cgi
tar -zxvf apache-maven-3.6.3
vi /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=$MAVEN_HOME/bin:$PATH
source /etc/profile
mvn -v
原文:https://www.cnblogs.com/zmh520/p/15267345.html