I've installed JDK 7u7 downloaded from oracle's website. But after installation, the terminal is still showing java version 6
$java -version
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
any idea why java 7 is not showing up?
Ans: OK, the problem has been resolved. Here is the answer: I found that my Terminal has a .bash_profile and the java home variable is set to 1.6
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"
So this is the line causing the problem every time I opened a new terminal window. Simply remove this line will solve the problem. but if that doesn't work for you, check the .bash_profile (or .bashrc) setting file to see if you've previously exported any java version.