I am trying to build my maven project on linux and for that I do mvn clean install but it says mvn:command not found. I have also verified my maven version and its correct then how can I build. Please tell.
Asked
Active
Viewed 5,065 times
3
-
Did you install maven? Have you tried calling it with its full path? – sleske Apr 24 '17 at 07:35
-
@sleske I have followed this tutorial https://www.tutorialspoint.com/maven/maven_environment_setup.htm – sahil saroop Apr 24 '17 at 07:48
-
@sleske how can I call with its path with ./mvn clean like this because mvn clean does not work – sahil saroop Apr 24 '17 at 07:50
-
No, `./mvn` will not work - that's for a file in the local directory. Call it as just `mvn`, like in the tutorial. The tutorial tells you to add Maven to your PATH, so just `mvn` will work. – sleske Apr 24 '17 at 08:15
-
@sleske even that also does not work so what should I do ? – sahil saroop Apr 24 '17 at 08:56
-
Sorry, but stackoverflow.com is for specific questions, not for one-on-one mentoring. You could try getting help in [chat](http://chat.stackoverflow.com/), once you have 20 rep points here. Voting to close.. – sleske Apr 24 '17 at 09:43
-
@sahilsaroop , which linux u using ? also can you post your pom.xml and exact error message with code , it will prevent your question to closed down and help other person to understand it better rather than going through your chat. – Amit Apr 24 '17 at 09:53
-
1@AmitK: If the problem is that "mvn" is not found, then posting the POM is unlikely to help... – sleske Apr 24 '17 at 09:55
1 Answers
0
For Linux you need the following in your ~/.bash_profile or ~/.profile, you are setting these environment variables:
JAVA_HOME=...../jdk1.8.0_92
M2_HOME=...../apache-maven-3.3.9
PATH="${JAVA_HOME}/bin:${M2_HOME}/bin:${PATH}"
Obviously .... needs to be set to the correct directory.
Make sure you start a new shell or source ~/.bash_profile or ~/.profile.

Essex Boy
- 7,565
- 2
- 21
- 24
-
-
thank you for updating but one question this in this ~/.bash_profile i should place JAVA_HOME=...../jdk1.8.0_92 M2_HOME=...../apache-maven-3.3.9 PATH="${JAVA_HOME}/bin:${M2_HOME}/bin:${PATH}" as it is ? and shall I create this bash file at the place where pom.xml exists? – sahil saroop Apr 24 '17 at 08:14
-
go to your home directory, with a cd, then a ls -al to show hidden files. You should have a .profile or .bash_profile these files control you shell. – Essex Boy Apr 24 '17 at 08:29
-
I created the bash profile like you said but when I go to my directory where my pom.xml is and then do mvn clean install it gives the same issue of mvn command not found – sahil saroop Apr 24 '17 at 08:50
-
You don't need to create the file it should already be I don't know what shell you're using. Do an ls -al to see what file you have. Do you know you're using bash, you need to figure this out, then you will know where to set your environment variables. Look up bash and .bash_profile and setting environment variables http://stackoverflow.com/questions/234742/setting-environment-variables-in-linux-using-bash – Essex Boy Apr 24 '17 at 09:04
-
when I do ls -al in my home directorey it gives 3 things one is my project and one is c other is public_htlm file – sahil saroop Apr 24 '17 at 11:10