When I opened Photoshop CS 5.1 for the first time a dialog box opened and when clicked took me to the Apple site to download JavaforOSX.
Here is the description from the installer:
Java for OS X 2015-001 installs the legacy Java SE 6 runtime.
This package is exclusively intended for support of legacy software, and installs the same deprecated version of Java SE 6 included in the 2013-005 release. If you require Java for applets or other non-legacy uses it is recommended you download the latest version of Java from https://java.com.
Please quit any Java applications before installing this update.
See https://support.apple.com/kb/HT6133 for more details about this update.
See https://support.apple.com/kb/HT1222 for information about the security content of this update.
The Java Preference Pane still shows that I am running Java 8 which is the latest build.
Hope this helps.