1

In CMD echo %JAVA_HOME% displays Java directory, does this work the same on unix. I have tried echo $JAVA_HOME.

2 Answers 2

1

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.

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

Comments

1

Type in terminal echo $JAVA_HOME. If nothing appears, set it with this command

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

This will differ according to your JDK type & version.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.