0
votes

I am trying to install maven on Ubuntu using the following steps :

  1. user$ wget http://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
  2. user$ tar -zxvf apache-maven-3.3.9-bin.tar.gz
  3. user$ export PATH=/usr/local/apache-maven-3.3.9/bin:$PATH

on doing
user$ echo $PATH

cli returns : /usr/local/apachemaven3.3.9/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

but on executing

user$ mvn -version

cli returns : The program 'mvn' can be found in the following packages:

  • maven
  • maven2

Try: sudo apt-get install

Is any step missing here ?

JAVA_HOME is already set :

user$ echo $JAVA_HOME

/usr/lib/jvm/java-8-oracle

2
replace export PATH=/usr/local/apache-maven-3.3.9/bin:$PATH by export PATH=USER/apache-maven-3.3.9/bin:$PATH where user is directory where you extracted archiveGarf365
Why are you installing manually? You have a package manager for this which can do this much better and will avoid conflicts and keep it up to date.Ingo Bürk

2 Answers

0
votes

In your path, you have /usr/local/apachemaven3.3.9/bin instead of /usr/local/apache-maven-3.3.9/bin.

Also I recommand you use an environment variable like MAVEN_HOME to save the location of Maven directory : /usr/local/apache-maven-3.3.9.

Then you can set your PATH to ${MAVEN_HOME}/bin:${PATH}.

That way you won't have to change your PATH if you have to change your Maven directory or version for example. You only have to change your MAVEN_HOME.

0
votes

You should set your environment variables in:

  1. /etc/environment
  2. /etc/profile

You can do it using the vi editor, and you'll need to it as super user. Like this:

sudo vi /etc/environment

Afterwards, restart your system or logout and log back in.