I set my JAVA_HOME path by using the command:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java
Then when I use this: echo $JAVA_HOME I get:
/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java
But when I close the terminal, and then open it and check echo $JAVA_HOME, the command will not get any result. That is, there is no JAVA_HOME set.
export only makes available the variable to the current and child processes, it is cleared, when you terminate your process.
You may put your export command into your ~/.bashrc file to have it always available.
So, open your ~/.bashrc file with a text editor, and put this into the first line:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/jre
save the file, and after a relog, you can always use the veriable in shell scripts.
Other option (actually the recommended one by Ubuntu documentation) is to put this line into /etc/environment, this way the variable will be set for all users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With