The first thing to understand about Oracle Java and systems running OS X 10.7 and above is that it is not an Application, so it doesn't really show up in the Software module (although two components do). The pieces of JAva that I care about are the PreferencePane and the Internet Plug-in. Also, Oracle didn't quite follow Apple's rules, they kinda faked it.
Java is Special.
Another item is that for OS X versions before 10.7, Java was built in; after that it is not and needs to be added.
Further complicating things is that Apple's XProtect. XProtect is a FIle Quarentine implementation that blocks known maleware (or vulnerable versions of some applications). It is built in to OS X 10.8 and later. If you are running updated Java (1.7_55 +) and at least Snow Leopard (Mavericks is free) it shouldn't effect you in a bad way. If you have a need to run Java 1.6, then you may want to check this thread:
Determining if JAVA is installed and if so, what version
Because Java is not an Application, but rather a set of plug-ins, determining the presence and the version of two compnents is key.
To make things more complicated, the PreferencePane is a link, not a real file. It links to:
So, since that is a sub section of the JavaAppletPlugin.plugin, it is the key.
To determine the version of the Plug-In, you can use the Get Info feature of the finder. From the command line that best way to do this is to grab it out of the Info.plist file that is found within the Plug-in bundle.
Unfortunately, this too is a link. So, the best way to determine the current version seems to be to use built in queries on the system like PlistBuddy or Defaults :
/usr/libexec/PlistBuddy -c "print :CFBundleVersion" "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist"
/usr/bin/defaults read /Library/Internet\ Plug-ins/JavaAppletPlugin.plugin/Contents/Info.plist CFBundleVersion
Either of which could be used as a Custom Inventory Return
ShellCommandTextReturn(/usr/libexec/PlistBuddy -c "print :CFBundleVersion" "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist")
Note: Using 'PlistValueReturn' to do the same thing doesn't work because the link points to either 'Enabled.plist' or 'Disabled.plist' depending on the state.
This would work if it is Enabled...
PlistValueReturn(/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist, CFBundleVersion, TEXT)
Better yet, throw a small script on the systems and then run the script with the CI (save in /usr/local/bin/java_ver.sh)
if [ -f "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist" ] ; then VERSION=$( defaults read "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist" CFBundleVersion )
else [ -f "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Disabled.plist" ]
Then build out your CIR:
Installing Java 1.7_60 b19
OK, so know we know what version is installed. If you want to make a Managed Install for Java the next step would be to make a specific Software Record for that specific version of Java. For this example I will talk about Java Standard Version 7 Update 60 (CFBundleVersion returns 18.104.22.168)
PlistValueEquals(/Library/Internet\ Plug-ins/JavaAppletPlugin.plugin/Contents/Enabled.plist, CFBundleVersion, TEXT, 22.214.171.124) OR PlistValueEquals(/Library/Internet\ Plug-ins/JavaAppletPlugin.plugin/Contents/Disabled.plist, CFBundleVersion, TEXT, 126.96.36.199)
Select all your 10.7 and above Operating Systems
Browse to FIle: jre-7u60-macosx-x64.dmg
The Managed Install in Distribution is stadard for OS X. Just let it do it. :)
Option Disable Java Auto Update:
You could add this to the script that returns the version and it will turn off the auto update feature in Java.
defaults write /Library/Preferences/com.oracle.java.Java-Updater JavaAutoUpdateEnabled -bool false
Java FAQ (Oracle):
XProtect re-Enable Java 6 & 7:
Managing Oracle Java Exception Site List: