How to install maven on redhat linux

后端 未结 5 2147
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 08:23

Note: When originally posted I was trying to install maven2. Since the main answer is for maven3 I have updated the title. The rest of the question remains as it was origina

5条回答
  •  情书的邮戳
    2020-12-13 09:04

    Pretty much what others said, but using "~/.bash_profile" and step by step (for beginners):

    1. Move to home folder and create a new folder for maven artifacts:
      • cd ~ && mkdir installed-packages
    2. Go to https://maven.apache.org/download.cgi and wget the latest artifact:
      • If you don't have wget installed: sudo yum install -y wget
      • cd ~/installed-packages
      • wget http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
    3. Uncompress the downloaded file:
      • tar -xvf apache-maven-3.5.0-bin.tar.gz
    4. Create a symbolic link of the uncompressed file:
      • ln -s ~/installed-packages/apache-maven-3.5.0 /usr/local/apache-maven
    5. Edit ~/.bash_profile (This is where environment variables are commonly stored):
      • vi ~/.bash_profile
      • Add the variable: MVN_HOME=/usr/local/apache-maven (do this before PATH variable is defined)
        • (For those who don't know vi tool: Press i key to enable insert mode)
      • Go to the end of the line where PATH variable is defined and append the following: :$MVN_HOME:$MVN_HOME/bin
      • Save changes
        • (For those who don't know vi tool: Press esc key to exit insert mode and :wq! to save and quit file)
    6. Reload environment variables:
      • source ~/.bash_profile
    7. Confirm that maven command now works properly:
      • mvn --help

提交回复
热议问题