Maven is a java building tool which can uses for compile,run test, install, etc.. Today I'm going to tell you how to install maven2/maven3 in ubuntu by manually and by apt-get package manager.
Install Maven2 manually
1. First you need to download maven 2.2.1 binary file.
2.Extract downloaded binary file to a directory where you like to keep maven . Let's say you created a directory call "maven-2.2.1" in your home directory.
3. Now you need to set maven classpath in ".bashrc" file.
i. Open your terminal and type "cd" to go to home directory where .bashrc has located
ii. Now Type "gedit .bashrc" in your terminal. It will open .bashrc file via gedit.
iii. Add this line to the end of .bashrc file "export PATH=/home/your_home_directory_name/maven-2.2.1/bin:$PATH" (note: replace your home directory name with "your_home_directory_name", i have added "export PATH=/home/shameera/maven-2.2.1/bin:$PATH" as my home directory name is "shameera")
4. Save and close .bashrc file.
5. Get a new terminal and type "mvn --version" then you will get below line and some other information like java versin and java home. If you need to install oracal(sun) java 1.7 on your machine see my previous post Install Oracle(sun) jdk 1.7 in ubuntu.
Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
6. If you get same out put then you have installed maven2 on your machine. NOTE: if you used previous terminal for this before type "mvn --version" type "source .bashrc".
Install Maven3 using manual
This is same as Maven2 installation. Download apache-maven-3.0.4 instead of maven2
Install Maven2 using apt-get
Open a new terminal and type "sudo apt-get install maven2". Then it will ask your password type your password. After that it will ask to install some necessary packages including openjdk if you like to install openjdk on your machine type "y" if not type "n" and use Install Maven2 manuall procedure to install maven2/maven3 on your machine.
Install Maven2 manually
1. First you need to download maven 2.2.1 binary file.
2.Extract downloaded binary file to a directory where you like to keep maven . Let's say you created a directory call "maven-2.2.1" in your home directory.
3. Now you need to set maven classpath in ".bashrc" file.
i. Open your terminal and type "cd" to go to home directory where .bashrc has located
ii. Now Type "gedit .bashrc" in your terminal. It will open .bashrc file via gedit.
iii. Add this line to the end of .bashrc file "export PATH=/home/your_home_directory_name/maven-2.2.1/bin:$PATH" (note: replace your home directory name with "your_home_directory_name", i have added "export PATH=/home/shameera/maven-2.2.1/bin:$PATH" as my home directory name is "shameera")
4. Save and close .bashrc file.
5. Get a new terminal and type "mvn --version" then you will get below line and some other information like java versin and java home. If you need to install oracal(sun) java 1.7 on your machine see my previous post Install Oracle(sun) jdk 1.7 in ubuntu.
Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
6. If you get same out put then you have installed maven2 on your machine. NOTE: if you used previous terminal for this before type "mvn --version" type "source .bashrc".
Install Maven3 using manual
This is same as Maven2 installation. Download apache-maven-3.0.4 instead of maven2
Install Maven2 using apt-get
Open a new terminal and type "sudo apt-get install maven2". Then it will ask your password type your password. After that it will ask to install some necessary packages including openjdk if you like to install openjdk on your machine type "y" if not type "n" and use Install Maven2 manuall procedure to install maven2/maven3 on your machine.
Good article. Have one comment.
ReplyDeleteIsn't that,
"export PATH=/home/your_home_directory_name/maven-2.2.1/bin:$PATH"
Thanks Duminda to point out this, yes it is i have corrected.
Delete