How to update Java from 8 Update 31 to 8 Update 51 when install fails?

I'm trying to update Java on my Mac OSX Yosemite. In the Java Control Panel, it states:

A critical Java security update is available.

8 Update 51 (57 MB)

Your current version is Java 8 Update 31. It is recommended that you update 
now to keep your system secure.

I click the Update Now button and it brings up the Software Update dialog that indicates I must relaunch the browser to update, but it will not need to reboot the computer. I click the Install Update button which brings up the Updating Java dialog that downloads 60 MB, extracts it, and then very briefly says ready to update before disappearing. Returning to the Java Control Panel shows I'm still on Update 31, repeating the process has same result.

How can I get the update to actually install?


Solution 1:

No need to uninstall the current version. From the Java website just download the Java 8 update 51 (JDK)from Oracle site and install manually. After installation, no need to reboot the machine. Check version in Terminal or Java panel. It will show the updated version.

Solution 2:

When an automated update process fails without an explicit reason then one method of dealing with it is to manually uninstalled the present installed version and then install the current full version downloaded manually from the source website.

Looking at How do I uninstall Java on my Mac?, which applies to versions 7.0, 8.0 on OS X for the JRE, one needs to do the following:

Uninstall Oracle Java using the Terminal

Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo.
Remove one directory and one file (a symlink), as follows:

  1. Click on the Finder icon located in your dock
  2. Click on the Utilities folder
  3. Double-click on the Terminal icon
  4. In the Terminal window Copy and Paste the command below:

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

    sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefpane

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.

Manually download the latest version from: Java SE Downloads

Note: For normal Browser usage choose the JRE however if wanting to use the latest Java from the Command Line in a Terminal choose the JDK. Additionally if you already have the Java JDK installed I noticed that after updating from version 1.8.0_45 to 1.8.0_51 via the Java Control Panel under System Preferences that it only updated the JRE components to version1.8.0_51, not the JDK and it remained at 1.8.0_45.

So I uninstalled the JDK following the directions in Uninstalling the JDK as well as the commands from the directions listed above.

Uninstalling the JDK To uninstall the JDK, you must have Administrator privileges and execute the remove command either as root or by using the sudo(8) tool.

Navigate to /Library/Java/JavaVirtualMachines and remove the directory whose name matches the following format:*

/Library/Java/JavaVirtualMachines/jdk<major>.<minor>.<macro[_update]>.jdk

For example, to uninstall 7u6:

% rm -rf jdk1.7.0_06.jdk

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 7u4 and 7u5 releases were installed into a directory that does not follow this format. To uninstall 7u4 or 7u5, remove the 1.7.0.jdk directory from the same location.

I then downloaded the current JDK and installed it and am now using the latest version of Java both in a Browser and the Command Line in a Terminal.