I tried to install Maven on CentOS 7, but afterwards typing mvn -version
in the terminal results in bash: mvn: command not found...
. How can I fix this so that I can call maven from the CentOS 7 terminal?
The steps I took are from this tutorial, and they are also described explicitly and entirely as follows:
wget http://www.eng.lsu.edu/mirrors/apache/maven/maven-3/3.3.1/binaries/apache-maven-3.3.1-bin.zip
unzip apache-maven-3.3.1-bin.zip
mkdir /opt/maven
mv apache-maven-3.3.1/ /opt/maven
ln -s /opt/maven/bin/mvn /usr/bin/mvn
gedit /etc/profile.d/maven.sh
Add the following contents to /etc/profile.d/maven.sh :
#!/bin/bash
MAVEN_HOME=/opt/maven
PATH=$MAVEN_HOME/bin:$PATH
export PATH MAVEN_HOME
export CLASSPATH=.
Save and close the file. Then:
chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh
Log out or reboot the computer. Then (with username and results shown this time):
[root@localhost ~]# mvn -version
bash: mvn: command not found...
[root@localhost ~]# mvn --version
bash: mvn: command not found...
[root@localhost ~]# echo $MAVEN_HOME
/opt/maven
Note that I did not install Ant. Also, the tomcat installation was done separately long ago.
EDIT
As per @MarkPlotnick's advice, I tried the following, with the following results:
[root@localhost ~]# mv /opt/maven /opt/maven.bak
[root@localhost ~]# mv /opt/maven.bak/apache-maven-3.3.1 /opt/maven
[root@localhost ~]# mvn -version
Apache Maven 3.3.1 (lotsnumbersandletters; 2015-03-13T13:10:27-07:00)
Maven home: /opt/maven
Java version: 1.7.0_71, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_71/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "versionnumber", arch: "amd64", family: "unix"
mv /opt/maven /opt/maven.bak; mv /opt/maven.bak/apache-maven-3.3.1 /opt/maven
and see if things work after that.