Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to install apache maven 3 in Ubuntu 12.04 lts. What I did was open the terminal then I typed the following commands

  • export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.5 [Then pressed Enter]
  • export M2=$M2_HOME/bin [Then pressed Enter]
  • export PATH=$M2:$PATH [Then pressed Enter]

After that I typed

mvn --version

and it displayed all the necessary information but after closing the terminal, again I typed the command mvn --version

then it said that 'mvn' is not recognized

The program 'mvn' can be found in the following packages:
 * maven
 * maven2
Try sudo apt-get install <selected-page>

is there a way to permanently add a PATH variable in Ubuntu?

share|improve this question

2 Answers 2

Add those export lines to your ~/.profile file.

If you want it to apply to all users on the system, put it in /etc/profile instead;

sudoedit /etc/profile

Once you've edited either, you'll see the effect next time you log in.

See also http://mywiki.wooledge.org/DotFiles

On a side-note, if you instead install maven via the software center or apt-get, you won't need to do any of the above.

share|improve this answer
    
I tried the apt-get but it is the old version. I am using 12.04 lts. anyways where would I place it here? I already tried sudoedit /etc/profile but i have no idea where to place it here –  user962206 Jun 19 '13 at 9:15
    
@user962206, You can put them at the very end. –  geirha Jun 19 '13 at 13:28

This might help to add the environment variable permanently. Use the following command, for editing the file:

sudo gedit /etc/environment

Then use this command, to source it:

$source /etc/environment

Reference - Installing Maven 3 on Ubuntu 10.04 LTS Server

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.