[컴] ubuntu 에서 maven 설치

linux 에서 메이븐 / maven 설치 /

ubuntu 에서 maven 설치

jdk 설치

java 설치

# 1.8 설치
$ sudo apt-get install openjdk-8-jdk
$ sudo apt-get update -y
$ sudo apt install default-jdk -y

JAVA_HOME 설정

$ su
...
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
outfile=/etc/environment
echo "PATH=$PATH:$JAVA_HOME/bin" > $outfile; echo >> $outfile; echo JAVA_HOME=$JAVA_HOME >> $outfile

source /etc/environment

여러 version 이 설치된 경우


$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

maven 설치

$ sudo apt-get install wget -y
...
$ wget https://mirrors.estointernet.in/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
...
$ tar -xvf apache-maven-3.6.3-bin.tar.gz

$ M2_HOME='/home/a/apps/apache-maven-3.6.3'
$ PATH=$PATH:$M2_HOME/bin
$ mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-52-generic", arch: "amd64", family: "unix"

See Also

  1. Gradle 을 사용해야 하는 이유(원본 : Why Build Your Java Projects with Gradle Rather than Ant or Maven?)
  2. maven 에서 profile
  3. VSCode 에서 간단한 Maven project 사용하기

Reference

  1. How to Install Maven on Linux (Ubuntu) - JournalDev
  2. How To Install Maven In Linux-Configure Maven In Linux

댓글 없음:

댓글 쓰기