You said "i want to use both version by only changing environment variable but it is not working"
What did you change - from what and to what? How did you change it? are you using and
IDE or from the command line?
When you then try and use the other version, what did happen - did the JVM crash? Did it say "java not recognized"? Did you get a Blue Screen of Death?
Are you trying to run the same .class files on both versions? are you trying to develop one program on 1.6 and a different one on 1.7?
By "use both version", are you talking running programs or developing programs?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors