Episode 3, Install Maven

Episode 3, Install Maven

Season 1 - From Lame to Fame

  1. Open an internet browser

  2. Navigate to https://maven.apache.org/download.cgi

  3. Scroll down to Files and click on a link next to Binary … archive

  4. Usually you would go for .zip version

  5. Once downloaded, extract the contents of the archive to a directory you prefer

    1. Make sure the extracted content stays in a single folder
    2. Usually named like apache-maven-3.6.3
  6. In the end you’ll have Maven files looking like

    Make sure you do not have Maven in a nested directory like: /home/$USER/Apps/apache-maven-3.6.3/apache-maven-3.6.3, notice apache-maven-3.6.3 written 2 times

  7. Great, now we have Maven installed

  8. Now we need to make it work like a command in terminal

    1. In my case, I’ve extracted maven here /home/$USER/Apps/apache-maven-3.6.3 and I’ll use this path as reference
    2. Now we have to open ~/.bashrc with an editor

    Console way

    1. Press Ctrl + Alt + T to open a console
    2. Type nano ~/.bashrc and hit Enter, because this key is the meaning of the universe
    3. Navigate to the very end of this file with mouse scroll, Arrow Down or Page Down
    4. Type this
    export MVN_HOME=/home/$USER/Apps/apache-maven-3.6.3 # declare MVN_HOME variable with value equal to the location of Maven app 
    export M2=$MVN_HOME/bin # declare M2 variable with value equal to the location of the [mvn] binary (executable), we re-use $MVN_HOME variable to make the value shorter
    export PATH=$PATH:$M2 # Add our $M2 to the global $PATH variable so that the terminal will know where to find [mvn] binary when we'll type it
    
    1. Press Ctrl + O to save changes Over, then Enter to confirm and Ctrl + X to eXit from nano
    2. Type source ~/.bashrc then Enter
    3. Type mvn --version then Enter

    Graphical way

    1. Open the file manager Win + E
    2. Press Ctrl + H to show/hide hiddne files (the ones that have their name starting with a dot, like .bashrc)
    3. Find file named .bashrc, double-click on it to open with a text editor
    4. Navigate to the very end of this file with mouse scroll, Arrow Down or Page Down
    5. Type this
    export MVN_HOME=/home/$USER/Apps/apache-maven-3.6.3 # declare MVN_HOME variable with value equal to the location of Maven app 
    export M2=$MVN_HOME/bin # declare M2 variable with value equal to the location of the [mvn] binary (executable), we re-use $MVN_HOME variable to make the value shorter
    export PATH=$PATH:$M2 # Add our $M2 to the global $PATH variable so that the terminal will know where to find [mvn] binary when we'll type it
    
    1. Press Ctrl + S to save and Alt + F4 to close the editor
    2. Press Ctrl + Alt + T to open a console
    3. Type mvn --version then Enter
    1. In my case, I’ve extracted maven here C:\apache-maven-3.6.3 and I’ll use this path as reference

    Console way

    1. Open cmd (command.com, command or simply cmd)

      • Press Win + R type cmd and press Enter
    2. Declare MVN_HOME variable with value equal to the location of Maven app

      • Type setx MVN_HOME "C:\apache-maven-3.6.3" and hit Enter
    3. Declare M2 variable with value equal to the location of the [mvn] binary (executable), we re-use $MVN_HOME variable to make the value shorter

      • Type setx M2 "%MVN_HOME%\bin" and hit Enter
    4. Add our %M2% to the global $PATH variable so that the terminal will know where to find [mvn] binary when we’ll type it

      • Type setx PATH "%M2%;%PATH%" and hit Enter
    5. Close cmd and open it again, see step #1

    6. Type mvn --version then Enter