Welcome to Mac world !! You need to download Java from this site and install it on your system. After that, open your terminal and type
javac -version
You will see that it still shows your java version 1.7.
What you need to do next is using java_home
to check the path of the java 1.6
$ /usr/libexec/java_home -v 1.6
/Library/Java/JavaVirtualMachines/1.6.0_45-b06-451.jdk/Contents/Home
$ /usr/libexec/java_home -v 1.7
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
So, whenever you need 1.6 or 1.7, you can set the path of the particular version in /User/<your-account>/.bash_profile
. For example:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.6.0_45-b06-451.jdk/Contents/Home"
# export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home"