sireesha, since you are having problems compiling, post the output of
which is different from above.
java is the command for running the application while
javac is used for compiling your classes. By default, some systems (like my Ubuntu system), contains symlinks to the 1.4 version for the javac command, which obviously can present problems. If this is the case for you, you would simply need to make the link for the javac command to your more updated jvm, in your case 1.6.