0

Apologies in advance if this question is very simplistic! I have Ubuntu 12.04. I manually installed Maven by downloading the binary tarball file and extracting it to the /opt/ folder. I then set the relevant export variables with the following commands:

export M2_HOME=/opt/apache-maven-3.0.5
export PATH=$PATH:$M2_HOME/bin

For good measure, I added these into the /home/andrew/.bashrc file (with andrew being the main user profile). However, I later realised that obviously this only set the path variables for that particular user. When I change to a secondary user, they don't detect the maven installation as they don't have the export variables.

How do I set global variables to govern something like this?

4
  • 1
    The above link will answer your question, but, IMO, it is better to place your binary in /usr/local , /usr/local/bin, for example, is on your path. Better, I would use this ppa - launchpad.net/~natecarlson/+archive/maven3
    – Panther
    Jul 12, 2013 at 21:13
  • So if I install Maven to /usr/local/ does that mean I don't need to export any variables as the location is already on a global path? Jul 12, 2013 at 21:50
  • If the tar ball is a single binary, put it in /usr/local/bin and it will be on your path. If there is more then a single binary, you would need to put the pieces in the correct location. In general, IMO, it is best to use a ppa and a .deb, see fedoraproject.org/wiki/Package_management_system It is written for Fedora, but the concept applies to all distros.
    – Panther
    Jul 12, 2013 at 21:54
  • To throw in yet another opinion, I'd also consider the possibility of installing in the default location and then adding symlinks from /usr/local/bin to $M2_HOME. This often makes cleaning up easier than if you had installed in /usr/local.
    – Joe
    Jul 12, 2013 at 23:13

0

Browse other questions tagged .