欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Centos7 安装jdk8 和 maven3  

程序员文章站 2022-07-03 12:46:53
...
centos7 安装jdk

检查是否已装有其他版本的JDK,执行命令:rpm -qa | grep java,
如上所示,当前已有openjdk的1.7和1.8版本,我们需要将其卸载;
卸载上一步发现的已装的jdk,执行以下命令:


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



下载jdk-8u161-linux-x64.tar.gz,官网地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


export JAVA_HOME=/usr/local/jdk1.8.0_151
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib/dt.JAVA_HOME/lib/tools.jar:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}












安装maven
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz



tar -zxvf apache-maven-3.3.9-bin.tar.gz

mv apache-maven-3.3.9 maven
(这一步骤可省略,主要是为了后面方便操作) 重命名
配置配置文件
vim /etc/profile


M3_HOME=/usr/local/tools/maven/maven
export PATH=${M3_HOME}/bin:${PATH}


配置文件生效
source /etc/profile

查看maven版本
mvn -v



Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/tools/maven/maven
Java version: 1.8.0_141, vendor: Oracle Corporation
Java home: /usr/local/tools/jdk1.8.0_141/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.1.3.el7.x86_64", arch: "amd64", family: "unix"