1

I am using Maven to the build process of my Java project.

To launch the mvn command in any position within the shell I am using the following command to declare the environment variable in this way:

export MAVEN_HOME=/home/andrea/SpringSource/apache-maven-3.0.4

export PATH=$PATH:$MAVEN_HOME/bin

The problem is that if I close my shell, when I open it again I have to give again the previous commands...how can I solve this problem and "save" the environment variable on my system?

Thank you

Andrea

2

You should save these commands as lines in your ~/.bashrc file. That way, these commands are applied/run each time you start a new instance of bash, i.e. each time you log in.

Otherwise:

  • To make the variables system-wide, disregarding which shell you use, assign the variables in /etc/environment (as described here) (alternatively in /etc/profiles).
  • To make the variables system-wide for bash (for all users using bash), place the lines in the file /etc/bash.bashrc (alternatively in /etc/bashrc on some other OSes than Ubuntu)
  • Note, you cannot use variables in /etc/environment, so $MAVEN_HOME, $PATH will not work. Only static values. – wisbucky Apr 18 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.