2

This question already has an answer here:

My environment variables are correct? What is the correct way to use them in Ubuntu? I put them at the end of .bashrc file or edit the end of /etc/environment to able to use the $JAVA_HOME and $M2_HOME configuration and on my user?

$JAVA_HOME

JAVA_HOME="/usr/lib/jvm/java-8-oracle/​"
CLASSPATH="JAVA_HOME/lib/:$CLASSPATH"
PATH="$JAVA_HOME/bin/:$PATH"

$M2_HOME

M2_HOME="/usr/share/maven/"
M2="$M2_HOME/bin"
PATH="$M2:$PATH" PATH=$M2:$PATH

marked as duplicate by heemayl, muru, Community Aug 6 '15 at 23:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

In bash you can set variables like this:

export JAVA_HOME=/usr/lib/jvm/java-8-oracle/​

export CLASSPATH=JAVA_HOME/lib/:$CLASSPATH
export PATH=$JAVA_HOME/bin/:$PATH
export M2_HOME=/usr/share/maven/
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

for more info on environment variables you can read https://help.ubuntu.com/community/EnvironmentVariables

  • the export when I restart the computer lose the settings – ricardoramos Aug 6 '15 at 20:25
  • refer the link in answer and read the point Persistent environment variables – Prashant Chikhalkar Aug 6 '15 at 20:28
  • From what I understand Variable expansion is a form of Persistent environment variables, but does not work in /etc/environment. – ricardoramos Aug 6 '15 at 20:36
  • I think that the way will be putting them at the end of .bashrc file – ricardoramos Aug 6 '15 at 20:37
  • You can add it to the file .profile or .bashrc or your current shell profile file (located in your home directory). Then, each time you open your shell it will be loaded. This will help you unix.stackexchange.com/questions/117467/… – Prashant Chikhalkar Aug 6 '15 at 20:38

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