When you have several java versions in your machine you could use below command to change the version you required.
/usr/sbin/alternatives --config java
This will ask to choose you a number and number contains the version belongs to it.
Hope this helps you.