Run java bundled in .app from command-line
To switch to another JVM, try to modify the JAVA_HOME and PATH shell environment variable in ~/.profile.

# in ~/.profile
# switch to another JVM (here, 1.7)
unset JAVA_HOME PATH
export JAVA_HOME="$(/usr/libexec/java_home -F --version 1.7 2&gt;/dev/null)"
export PATH="${JAVA_HOME}/bin:${PATH}"

# general info on Java preferences
open -a 'Java Preferences'