Put these aliases in your ~/.bash_profile or ~/.profile, reload the profile and you're ready to go. BTW, if you haven't switched from iTerm to iTerm2 yet, you should do it now ;-).
alias setjdk16='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6*)'
alias setjdk17='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7*)'
How to Change JDK Version From the Command Line
About Bruce Snyder
Bruce Snyder is a veteran of enterprise software development and a recognized leader in open source software. With over a decade of experience, Bruce has worked with a wide range of technologies including Java EE, Enterprise Messaging and Service Oriented Integration. In addition to his role as a senior software engineer at SpringSource, Bruce is also an Apache Member, a co-founder of Apache Geronimo and a developer for Apache ActiveMQ, Apache Camel and Apache ServiceMix. He is the co-author of Professional Apache Geronimo, Beginning Spring Framework 2 both from Wrox Press and is currently co-authoring ActiveMQ In Action for Manning Publications. Bruce also serves as a member of various JCP expert groups and is a recognized international speaker at industry conferences. Bruce lives in beautiful Boulder, Colorado with his family.More About Bruce »
NFJS, the MagazineMay Issue Now Available
On the road to learningby Raju Gandhi
Refactoring to Modularityby Kirk Knoernschild
RESTful Groovyby Kenneth Kousen
Getting Started with D3.jsby Brian Sletten