Reputation: 799
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.
Upvotes: 3
Views: 1308
Reputation: 16041
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.
Upvotes: 4
Reputation: 113
to know java version use, java -showversion
To verify java path is set or not use echo $JAVA_HOME
Use following command to set java path
sudo gedit /etc/environment
In the file set JAVA_HOME
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre/
remember to provide the path completely upto the folder which contains bin/java
.
Restart system to activate the changes.
Upvotes: 1