MENU

Linux安装jdk1.8 mvn

• 2022 年 01 月 10 日 • Linux

Linux安装jdk1.8,mvn

一、下载jdk1.8、maven

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"  http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

# wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz --no-check-certificate

Mac方式

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-macosx-x64.dmg

二、部署

把jdk1.8和maven移动到/usr/local目录下(当然也可以移动到别的目录下,后面配置环境变量修改为自己的jdk路径即可)

# tar -zxvf jdk-8u131-linux-x64.tar.gz
# tar -xvf apache-maven-3.8.4-bin.tar.gz
# mv jdk1.8.0_131 jdk1.8
# mv -f apache-maven-3.8.4 /usr/local/
# mv jdk1.8 /usr/local

三、配置环境变量

1.修改/etc/profile文件

# vim /etc/profile

在profile文件中配置jdk环境

##set jdk
export JAVA_HOME=/usr/local/jdk1.8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
#set mvn
export MAVEN_HOME=/usr/local/apache-maven-3.8.4
export PATH=${PATH}:${MAVEN_HOME}/bin

2.使profile生效

# source /etc/profile