setting JAVA correctly on MAC
The only one that matters if running via /usr/bin/java is the value of JAVA_HOME and can be set for all terminals etc e.g. to get latest 1.7 add to your startup shell script (e.g. ~/.bashrc)

export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'


Unfortunately apps (ie GUI installed as OS X Application bundles e.g. Eclipse) access the java that is set up in their package information (Which can be a fullpath to one in /Library or /System/Library or could be /usr/bin/java) so they need to be looked at at a case by case basis.

The difference between installing a JDK in /Library/Java/JavaVirtualMachines vs /System/Library/Java/JavaVirtualMachines/ is that the latter is installed by Apple as part of the OS and the other is by a third party

The CurrentJDK is the way Apple versions OS X frameworks - in Java's case I don't think it matters now (in pre 1.7 days it might have been how the old Java preference tab worked but that is a guess)