How to downgrade Java.

In short:
Uninstall Java plugin (Java Web Start) for your browser type:

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

To remove a specific Java version go to:

/Library/Java/JavaVirtualMachines/

and remove the related jdk.

If you want to remove the Java Control Panel you have under ‘System Preferences’ type:

sudo rm /Library/PreferencePanes/JavaControlPanel.prefPane

NOTE: Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.

The long story:

Uninstalling Oracle Java ( java 6, java 7 or java 8 ) in most of the cases, only involves deleting the Java Plugin file: JavaAppletPlugin.plugin. In other words, you will delete the javaws (Java Web Start) that your browser uses.

Open your Terminal, copy and paste the following line:

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

However typing on your terminal

java -version

Still gives you the same version you have just deleted.

A practical example.

You have both version installed java 6 and java 7: in the specific java 1.6.0_65 and java 1.7.0_60 and you need to downgrade java 7 from 1.7.0_60 to 1.7.0_51

You remove the JavaAppletPlugin with the command above, then go to the terminal and type “java -version” and the result is still 1.7.0_60. Confused? Well you just removed the plugin from being use in the browser, nothing else. You can install now the latest java 7, but you will still see version 1.7.0_51 once typing ‘java -version’ on your terminal, which means that your browser will use java 1.7.0_60, but your Mac still recognises 1.7.0_51.

Screen Shot 2014-06-10 at 9.01.53 AM

The above picture shows that even if I have installed Java 1.7.0_60, my Mac still sees 1.7.0_51.

How can you get rid of 1.7.0_51 then? It is simple.
Remove

/Library/Java/JavaVirtualMachines/<version>.jdk/

In this case java sdk version 1.7.0_51.
This can be applied to every java version ( java 6, java 7, java 8 ) you want to remove.

Hold on, where is the latest java you just installed then? Well it is the latest, then you will find it here:

/System/Library/Frameworks/JavaVM.framework/Versions/Current/

In the future, when you upgrade, this is the place where your latest Java will be installed and the current version will be replaced automatically.

Remember: what described above occurs when you want to downgrade java version, not upgrade!

‘ok got it until here, but where is Java 6 installed?’

Well the system one is installed:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/