Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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