2
votes

I followed this tutorial to try install maven on my Remote Centos server

http://www.unixmen.com/install-apache-ant-maven-tomcat-centos-76-5/

I got /opt/maven when calling echo $MAVEN_HOME

And got

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/.nvm/versions/node/v0.12.7/bin:/root/bin

When calling echo $PATH

But when I call mvn -version It says:

-bash: mvn: command not found

4
Try running export PATH=$PATH:/opt/maven. Then try mvn -version.Ethan Strider

4 Answers

4
votes

Because you setup environment variables incorrectly. Try this section carefully: Setup Maven environment variable in your tutorial what you have been seen.

2
votes

Most important command :

sudo ln -s /your_path/apache-maven-3.6.2/bin/mvn /usr/bin/mvn
2
votes

First download latest version from :

> http://maven.apache.org/
> go to download
> download apache-maven-3.5.0-src.tar.gz

Execute following commands :

> sudo tar xzf apache-maven-3.5.0-src.tar.gz -C /opt
> cd /opt
> Create symlink
    sudo ln -s apache-maven-3.5.0 maven

Next, set up Maven path system-wide :

> sudo gedit /etc/profile.d/maven.sh
> export M2_HOME=/opt/maven
> export PATH=${M2_HOME}/bin:${PATH}

Finally, log out and log in again to activate the above environment variables. To verify the successful installation of maven, check the version of maven:: > mvn -version

Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30) Maven home: /opt/maven Java version: 1.8.0_45, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_45/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-862.11.6.el7.x86_64", arch: "amd64", family: "unix"

0
votes

Go to maven official website link

 >  Download latest version apache-maven-3.6.3-src.tar.gz
 >  Extract it into a location.
 >  Open .bashrc file in home location ( if not found then , ctrl + h)
 >  Add maven path

#maven

export PATH="$PATH:

for example: export PATH="$PATH:/home/nimal/apache-maven-3.6.3/bin"

check version :

mvn --version

enter image description here