Wednesday, January 27, 2016

Install Maven in UNIX systems

Install Maven in UNIX systems

Download Apache Maven from the following link

https://maven.apache.org/download.cgi


  • Open Terminal (Command + Space and type Terminal)
  • Open .bash_profile file in vim editor.
    • Type command    vim ~/.bash_profile
    • If file is not present create it in home folder with 
      • touch .bash_profile
    • Press 'i' to edit .bash_profile.
  • Type the following in .bash_profile
    • export JAVA_HOME=/Library/Java/JavaVirtualMachines/{jdk_version}/Contents/Home
    • export M2_HOME=/Downloads/apache-maven-3.*.*/
    • export PATH=$PATH:$M2_HOME/bin
    • alias mvn='$M2_HOME/bin/mvn'
  • Press Esc to exit editing and type :wq to  write and exit
  • Compile file for changes
    • source .bash_profile
  • To check whether the maven is configured properly use 
    • mvn -version
  • Your result must be something like this
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: /Users/skhatri/Downloads/apache-maven-3.3.9
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"