1

I configured the environment variables $JAVA_HOME and $M2_HOME the etc/environment file through the root, as follows:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:
JAVA_HOME=/usr/lib/jvm/java-8-oracle/​:
CLASSPATH=$JAVA_HOME/lib/:
CLASSPATH:PATH=$JAVA_HOME/bin/:PATH:
$M2_HOME=/usr/share/maven/:
M2=$M2_HOME/bin:
PATH=$M2:$PATH"

broken lines for ease of viewing.

After restart the computer and type the command echo $JAVA_HOME or echo "$JAVA_HOME" displays nothing.

Where am I wrong?

4
  • 1
    You might be better off asking on askbuntu Commented Aug 6, 2015 at 19:32
  • 2
    All your variables are faulty. $M2_HOME=... should be M2_HOME=...; your XXX_HOME should not end with :, you have for some reason a " after PATH and at the last line. Shortly, your structure is completely wrong. Commented Aug 6, 2015 at 19:32
  • Hello Olivier Grégoire that was another doubt, what is the correct way to use the environment variables and where to put them? Commented Aug 6, 2015 at 19:43
  • Olivier Grégoire is now correct? I insert them at the end of .bashrc file? JAVA_HOME=/usr/lib/jvm/java-8-oracle/​ CLASSPATH=$JAVA_HOME/lib/‌​CLASSPATH PATH=$JAVA_HOME/bin/:PATH M2_HOME=/usr/share/maven/ M2=$M2_HOME/bin PA‌​TH=$M2:$PATH Commented Aug 6, 2015 at 19:52

1 Answer 1

1

Variable expansion does not work in /etc/environment.

https://help.ubuntu.com/community/EnvironmentVariables#A.2Fetc.2Fenvironment

Also it is not clear why do you have colons at the end of each line. PATH seems to have unclosed quote.

Maybe you should post the original file without line breaks?

Sign up to request clarification or add additional context in comments.

2 Comments

So the correct would put my ambinte variables at the end of my .bashrc file?
Dmitry Lukashin used the colon as a separator PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:JAVA_HOME=/usr/lib/jvm/java-8-oracle/​:CLASSPATH=$JAVA_HOME/lib/:CLASSPATH:PATH=$JAVA_HOME/bin/:PATH:$M2_HOME=/usr/share/maven/:M2=$M2_HOME/bin:PATH=$M2:$PATH"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.