2

I am running Ubuntu 12.04 and am a Java developer who has recently moved off his desktop and started working on a new laptop. I have a few build issues and am investigating my install of Maven.

I got some help setting up my laptop and find the following Maven configuration confusing. I have Maven installed (by a peer I assume) and running but have no M2_HOME. I would have thought it would be a requirement.

The following is my output when I run mvn --version

Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_GB, platform encoding: UTF-8 
OS name: "linux", version: "3.5.0-23-generic", arch: "amd64", family: "unix"

None of the following give me anything: printenv | grep "maven", printenv | grep "mvn", printenv | grep "M2".

There is nothing special in ~/.profile or /etc/environment related to Maven.


Can you provide any clues/direction as to why mvn --version in the console gives output?

Crowie
  • 442
  • 1
  • 5
  • 19

3 Answers3

1

First, it is not MAVEN_HOME but like it is written into the title M2_HOME... The following assertion is true : the mvn command is in your path... The mvn command will function correctly if you were assigned a home directory...

In the home dir, you will find a directory .m2. In $HOME/.m2 you will find the maven repository and the file settins.xml. You don't need a M2_HOME (tested) but you need a JAVA_HOME...

blade19899
  • 26,704
  • So because .m2 is in my home directory it works? – Crowie Feb 12 '14 at 15:32
  • Yes it is because mvn can retrieve the .m2 directory related to the home directory of the user that everything works as expected... Try to rename .m2 to .m2.disabled... The directory will be recreated like the first time you did a mvn on this machine... – Rudy Vissers Feb 12 '14 at 15:39
  • Okay but why is Maven executable with no M2_HOME? What is making Maven accessible? – Crowie Feb 12 '14 at 16:20
  • ...and nothing visible on any PATH components – Crowie Feb 12 '14 at 16:21
  • This is not possible... If you are in a terminal and you type 'mvn' and that bash is able to find the 'mvn' command then 'mvn' has to be in your path... Isn't it ? – Rudy Vissers Feb 13 '14 at 09:57
  • This was the question - it was running and responding with the results in the question but nothing configured was visible in path. In around 24 hours I'll come back to it. I added it to ~/.profile to get it working – Crowie Feb 13 '14 at 10:08
  • Added an answer to this question. Let me know what you think about that and if you think that that is the cause of why Maven runs when I can't see it on the PATH with printenv. Appreciate your help – Crowie Feb 14 '14 at 12:09
  • It is a totally expected behaviour. Even if it is confusing for you. I was a Sun Enginner and in Solaris, by example, after you had installed the Java package it was installed in directories that were... what can
  • – Rudy Vissers Feb 16 '14 at 07:33