Currently in my Mac I have these JAVA versions:
MyMac$ cd /Library/Java/JavaVirtualMachines
$ ls -la
total 0
drwxr-xr-x 4 root wheel
El Capitan new feature: System Integrity Protection (SIP), was the cause of this problem. I had to disable SIP first.
Follow these steps to disable SIP:
Restart your Mac. Before OS X starts up, hold down Command-R and keep it held down until you see an Apple icon and a progress bar. Release. This boots you into Recovery. From the Utilities menu, select Terminal. At the prompt type exactly the following and then press Return:
csrutil disable
Terminal should display a message that SIP was disabled.
From the apple menu, select Restart.
You can re-enable SIP by following the above steps, but using csrutil enable instead.