I am using Linux
I downloaded the latest linux version from here
uploaded the .bin file to /home/asimon/java
executed the following commands
chmod 755 jdk-6u22-linux-i586.bin
./jdk-6u22-linux-i586.bin
and jdk1.6.0_22 was created, but whenever i try to execute java -version from /home/asimon/java/jdk1.6.0_22/bin i get the below output, i.e., not 1.6.0 but 1.4.2. What is creating the problem. I am also giving a screenshot of my set
Screenshot 1

my set output screenshot

Type
which javato find out which directoryjavais being picked up from. You probably need to correct your PATH. At the moment, you have/home/asimon/java/binon your PATH, which must be an old version of java. You should update it to/home/asimon/java/jdk1.6.0_22/bin. The PATH variable would be present in$HOME/.profile.Also, note that if you execute
./java -versionit will use the java executable present in the current working directory, instead of searching the PATH for it.