The other day i wanted to test something on JVM 7 .
There are many post related to this some are very complex to setup i wanted to have something quick juggad
after googling and help from my friend here is the easy way to do it .
1 . define JAVA_HOME variables
$ vim .bash_profile
here , here i comment JDK 8 version as now i want to use 7 .
2. compile :
$ source .bash_profile
3.$ echo $JAVA_HOME
here you will see /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home but in order to use it we have to hit following command .
4 . $ /usr/libexec/java_home -v 1.7
and here it worked for me .
I refer This post .
For details please refer