CentOS Stream8にApache Mavenをインストールする方法
1.OSとjavaバージョン確認
# cat /etc/redhat-release
CentOS Stream release 8
# java -version
openjdk version “1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
2.Javaのパスの確認
# dirname $(readlink $(readlink $(which java)))
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-4.el8.x86_64/jre/bin
3.Mavenファイルをダウンロード
# cd /usr/local/src
# wget https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
4.ファイルを解凍
# tar -zxvf apache-maven-3.6.3-bin.tar.gz
5.フォルダ名を変更
# mv apache-maven-3.6.3 maven
6.mavenを設定
# vi /etc/profile.d/maven.sh
追記
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-4.el8.x86_64/
export M2_HOME=/usr/local/src/maven
export PATH=${M2_HOME}/bin:${PATH}
設定を反映
# source /etc/profile.d/maven.sh
7.mvnバージョン確認
# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/src/maven
Java version: 1.8.0_282, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-4.el8.x86_64/jre
Default locale: ja_JP, platform encoding: UTF-8
OS name: “linux", version: “4.18.0-277.el8.x86_64", arch: “amd64", family: “unix"