Adding a bin
directory to your $PATH is quite acceptable. External 3rd party binaries should be placed in /opt
directory. Filesystem hierarchy should be followed & consistant.
/opt/<provider or package>/bin
Maven's documentation encourages installation under /usr/local/apache-maven/<package>
. This is also a common practice, but I found updating $PATH can be an unnecessary headache with package version updates & rollbacks. Instead, I'll place each package under /opt
, and create a symbolic link to /usr/local/maven
. At which point, I'd update $PATH to /usr/loca/maven/bin
and update the link as needed.
How I'd install Maven
- Extract downloaded package to
/opt
directory
cd /opt
tar zvxf ~/Downloads/apache-maven-3.0.4-bin.tar.gz
- Create symbolic link
ln -s /opt/apache-maven-3.0.4 /usr/local/maven
- Update $PATH
echo "export $PATH=/usr/local/maven/bin:$PATH" >> ~/.profile
source ~/.bash_profile
If and when a new version comes along
Repeat the above steps; except, remove old link first.
- Remove old link
- Recreate link to new version
ln -s /opt/apache-maven-3.0.5 /usr/local/maven