From the official Oracle manual.
Navigate to
/Library/Java/JavaVirtualMachinesand remove the directory whose name matches the following format:/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdkFor example, to uninstall 8u6:
%rm -rf jdk1.8.0_06.jdkDo 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.
To remove system files you need to add sudo before rm -rf command.