setting java_home weird error
Question
I have an ubuntu machine..
In my ~/.bashrc I have set java_home as
export JAVA_HOME=/usr/java/jdk1.7.0_04/bin/java
export PATH=$JAVA_HOME/bin:$PATH
but still when i do
$which java
I get
/usr/bin/java
what can be the reason? Any help would be greatly appreciated Thanks
Solution
Try echo $JAVA_HOME
and echo $PATH
and you will see that they have been set correctly. The problem is you are asking the shell where is the executable java and it's not looking at the JAVA_HOME variable.
If you've just edited your .bashrc, you will need to manually run the file, or login to your shell again to pick up the changes.
You have 2 choices:
- Refer to the specific jdk you want to use on a per use basis
- Update the default java using update-alternatives as described here
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow