Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 4096  / 2 Years ago, thu, september 1, 2022, 1:20:51

I set my JAVA_HOME using the instructions given here - https://gist.github.com/senthil245/6093389
Basically, we download a jdk bin file, unpack it, move it to /usr/lib/jvm and then set the environment variable JAVA_HOME using sudo vi /etc/environment.



I entered and saved JAVA_HOME="/usr/lib/jvm/jdk1.6.0_31"
But, when I do echo $JAVA_HOME, I get /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java



Why does this happen and how can I fix it ?


More From » 14.04

 Answers
2

You need to run:



source /etc/environment


so that the variables declared on the /etc/environment are available on the current shell and you will get the value of the variable set from the current shell. To make the variable available to all child processes of the shell, export it after source-ing:



export JAVA_HOME


Otherwise you have to logout from the current session and login again to have the variable as environment variable set in the /etc/environment file.






On the other hand, if you want to set this only for yourself, you can set it in ~/.bashrc too by doing:



echo -e "
export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_31" >> ~/.bashrc && source ~/.bashrc

[#21038] Friday, September 2, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byishted

Total Points: 469
Total Questions: 113
Total Answers: 113

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;