Extract the archive to to /opt.
sudo tar -xzvf apache-maven-<version>-bin.tar.gz -C /opt
Now we need to tell shell where to find maven. We’ll do this in the system profile settings so it is available to all users.
sudo edit /etc/profile.d/maven.sh
export M2_HOME=/opt/apache-maven-3.2.5 export PATH=$PATH:$M2_HOME/bin
Quit and save from the editor.
Log out and back into the Raspberry Pi so the profile script takes effect and there it is. You can test that it is working with
and you should see that the maven version is shown as the version that you have downloaded