Create a wrapper script named appropriately (java6
?) with the following contents somewhere in your PATH
.
#!/bin/sh
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
exec $JAVA_HOME/bin/java "$@"
% java6 -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)