0

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

frazman
  • 32,081
  • 75
  • 184
  • 269
  • What are you trying to accomplish exactly? There are is the `update-alternatives` command for example, to use a different version of java – noel Sep 26 '12 at 03:04
  • 1
    have you logged out and logged in again? the .bashrc is read only once at each login – gigadot Sep 26 '12 at 03:23

1 Answers1

1

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:

  1. Refer to the specific jdk you want to use on a per use basis
  2. Update the default java using update-alternatives as described here
Romski
  • 1,912
  • 1
  • 12
  • 27