Maven - working with sudo or working with different versions
Sometimes, you have to run maven commands as sudo or run mvn using a different version. And sudo may not always use the path from your .bashrc or .zshrc.
You can double check this by comparing the results of these two commands
mvn --version
sudo mvn --version
If sudo is using a different version of mvn than the one you are expecting, or if you want to run mvn commands using a specific version, use the full path of mvn when running the command.
e.g.
sudo /home/explorer436/Documents/apache-maven-3.6.3/bin/mvn clean verify
sudo /home/explorer436/Documents/apache-maven-3.6.3/bin/mvn clean install
or
/home/explorer436/Documents/apache-maven-3.9.2/bin/mvn clean verify
/home/explorer436/Documents/apache-maven-3.9.2/bin/mvn clean install