8

Can anyone help me installing maven 3.0.5 in linux please?

I tried using wget, yum and tar command. All the commands are saying its not recognized as an external or internal command and now I am blank as to how to achieve it. Do we need to go to start->cmd and apply these commands??

And also please tell me how to set the environment variable. Please help me.

Thanks in advance.

NREZ
  • 942
  • 9
  • 13
Keerthana
  • 167
  • 3
  • 4
  • 9
  • Did you set the enviroment variable MAVEN_HOME ? – Reporter Jul 22 '13 at 11:30
  • Here is the answer: http://stackoverflow.com/questions/12076326/how-to-install-maven2-on-redhat-linux – mirkobrankovic Jul 22 '13 at 11:32
  • It's hard to figure much from the question, but it appears that you have messed up with the `PATH` environment variable (especially if `tar` cannot be recognised as a command). – devnull Jul 22 '13 at 11:33

3 Answers3

35

The first thing we need to do is to download the Maven tar file and untar it to a shared location on the workstation

wget http://mirrors.gigenet.com/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
su -c "tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /opt/" 

Setup the Maven Environment Variables in shared profile. The next step is to setup the Maven environment variables in a shared profile so all users on the system will get them import at login time.

su -c "vi /etc/profile.d/maven.sh"

# Add the following lines to maven.sh
export M2_HOME=/opt/apache-maven-3.0.5
export M2=$M2_HOME/bin
PATH=$M2:$PATH 

Now test your install of Maven. Logout of the system and then log back into it. Enter the following command:

[jsmith@regan ~]$ mvn -version 

If you did everything right your output should look something like the one below:

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 08:51:28-0500)
Maven home: /opt/apache-maven-3.0.5
Java version: 1.7.0_19, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-358.2.1.el6.i686", arch: "i386", family: "unix"
Chetan Potdar
  • 827
  • 1
  • 7
  • 12
3

The above link will not work,it was corrupted, If you want latest versions please find the below link: wget http://mirror.olnevhost.net/pub/apache/maven/binaries/apache-maven-3.0.5-bin.tar.gz

Steps:

  1. Download the file at /opt/Maven/apache-maven-3.0.5-bin.tar.gz
  2. Extract the file in same location tar xvf apache-maven-3.0.5-bin.tar.gz and Run.
  3. Open vi /etc/profile
  4. Paste these line:

    export M2_HOME=/opt/Maven/apache-maven-3.0.5

    export PATH=$PATH:$M2_HOME/bin

  5. Save the file.

  6. Run source /etc/profile
  7. Finally Run mvn -version and you will get the maven version

Maven installation done.

Saikat
  • 14,222
  • 20
  • 104
  • 125
0
echo $JAVA_HOME if returns empty(export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home)
echo $PATH if returns empty(export PATH=$PATH:$JAVA_HOME/bin)
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.3
export M2=$M2_HOME/bin
mvn --version
ALL SET *******

In case if this doesn't work after this step,

vi .profile
export PATH={$PATH}:'/usr/local/apache-maven/apache-maven-3.2.3/bin/
Gautam
  • 9
  • 3