Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2430  / 1 Year ago, thu, march 16, 2023, 10:07:11

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?


More From » maven-3

 Answers
0

When you do not understand something you have to investigate why it works the way it works... What you just did. And it is great!


In the case of Maven on Linux/Ubuntu you find confusing the locations where the software is installed... OK. But you have to get used... That is the way it works.

Maybe you are used to install maven yourselves and in it case you have the control of the location of the installation and you can even use M2_HOME. I will come back later on M2_HOME.


I did the same researches and for me it is not confusing at all... But of course the locations could be unexpected for some people...

I have installed the package maven2 to do the same investigations...



rudy@rudy-Inspiron-530:~$ sudo apt-get install maven2 (lot of output that was discarded)
rudy@rudy-Inspiron-530:~$ whereis mvn
mvn: /usr/bin/mvn /usr/bin/X11/mvn /usr/share/man/man1/mvn.1.gz
rudy@rudy-Inspiron-530:~$ ls -l /usr/bin/mvn
lrwxrwxrwx 1 root root 21 fév 16 08:23 /usr/bin/mvn -> /etc/alternatives/mvn
rudy@rudy-Inspiron-530:~$ ls -l /usr/bin/X11/mvn
lrwxrwxrwx 1 root root 21 fév 16 08:23 /usr/bin/X11/mvn -> /etc/alternatives/mvn
rudy@rudy-Inspiron-530:~$ ls -l /etc/alternatives/mvn
lrwxrwxrwx 1 root root 25 fév 16 08:23 /etc/alternatives/mvn -> /usr/share/maven2/bin/mvn
rudy@rudy-Inspiron-530:~$ ls -l /usr/share/maven2/bin/mvn
-rwxr-xr-x 1 root root 6331 jun 25 2013 /usr/share/maven2/bin/mvn



There are soft links that are used. I see in the path /usr/bin/mvn and /usr/bin/X11/mvn. Then /usr/bin/mvn, /usr/bin/X11/mvn and /etc/alternatives/mvn are ALL soft links.

There are several levels and of course it can confuse you...


The real thing is in /usr/share/maven2/bin/mvn.



rudy@rudy-Inspiron-530:/usr/bin$ file /usr/share/maven2/bin/mvn
/usr/share/maven2/bin/mvn: POSIX shell script, ASCII text executable



The command 'file' returns what thing you have to deal with...

In the case of /usr/share/maven2/bin/mvn. It is shell script !


You made the assumption that JAVA_HOME and M2_HOME and ... must be initialized and it is a false assumption... Those variables can help you and some other softwares to use a specific version of softwares. Some softwares does not even work without some of these variables... But when you are in a terminal (and you use the packages) you don't need those variables ! Everything will work without.


[#27044] Friday, March 17, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rcraftemur

Total Points: 118
Total Questions: 119
Total Answers: 144

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;