In CMD echo %JAVA_HOME%
displays Java directory, does this work the same on unix.
I have tried echo $JAVA_HOME
.
Yes it "works the same". The difference here is the way in which you're referencing envirnment variables. In linux you should use $variable
notation.
So in this case echo $JAVA_HOME
shows value of JAVA_HOME
environment variable, or nothing if it wasn't set.
echo JAVA_HOME
outputs just a string JAVA_HOME
To set environment variable you should use export JAVA_HOME=something
. If you'd like to have this saved between restarts you could add such line to ~/.bashrc
file.