Detecting the Oracle-supplied Java 7 browser plug-in

rtrouton
Release Candidate Programs Tester

Does anyone have an extensions attribute for detecting if someone is using the Oracle-supplied Java 7 browser plug-in? I'm trying to set up a smart group that identifies these Macs on my network.

6 REPLIES 6

hkim
Contributor II

Here's what I'm using for an Extension Attribute to detect Apple Java version

https://gist.github.com/3987294

I'm scoping it to "Java Version is 14.5.0"

I just re-read the question, for Oracle, I put together a quick and dirty Extension Attribute

https://gist.github.com/3987395

Suggestions and improvements always welcome

rtrouton
Release Candidate Programs Tester

I may have a start here, will keep working on it. A way to detect Apple vs Oracle Java:

defaults read /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info CFBundleIdentifier

With Apple Java, it'll return com.apple.java.JavaAppletPlugin. For Oracle, it returns com.oracle.java.JavaAppletPlugin

cvgs
Contributor II

I am currently using the following script for differentiation:

#!/bin/bash

# Christoph von Gabler-Sahm (christoph.gabler-sahm@computacenter.com)
# Version 1.0

# checks installed version of Java Applet Plugin
# returns values like "Not installed", "JavaInstallOnDemand: 14.5.0", "JavaJDK16: 14.5.0" or "Java 7 Update 09"

PLUGINPATH="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin"

# Plugin version
S_VERSION=$( /usr/bin/defaults read "${PLUGINPATH}/Contents/Info" CFBundleShortVersionString 2>/dev/null )

# JavaInstallOnDemand or empty
S_PROJECT=$( /usr/bin/defaults read "${PLUGINPATH}/Contents/version" ProjectName 2>/dev/null )

if [[ -e "${PLUGINPATH}" ]]; then
    if [[ "${S_PROJECT}" == "" ]]; then
        EA_RESULT="${S_VERSION}"
    else
        EA_RESULT="${S_PROJECT}: ${S_VERSION}"
    fi
else
    EA_RESULT="Not installed"
fi

echo "<result>${EA_RESULT}</result>"

hkim
Contributor II

Nice script! Thanks for sharing!

rtrouton
Release Candidate Programs Tester

Thanks, cvgs! I'm using your script and it works great for pulling the version. I've also put together an script for determining quickly who's the vendor (Apple or Oracle):

#!/bin/bash

javaVendor=`/usr/bin/defaults read /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info CFBundleIdentifier`

if [ "$javaVendor" = "com.oracle.java.JavaAppletPlugin" ]; then
        result=Oracle
elif [ "$javaVendor" = "com.apple.java.JavaAppletPlugin" ]; then
        result=Apple
elif [ "$javaVendor" = "" ]; then
        result="No Java Plug-In Available"
fi

echo "<result>$result</result>"

mthakur
Contributor

Note that the script does not work on Snow Leopard computers with Java 1.6 Update 9 installed. There is no JavaAppletPlugin.plugin in the /Library/Internet Plug-Ins folder:

$ pwd
/Library/Internet Plug-Ins
$ ls -d *Java
JavaPlugin2_NPAPI.plugin JavaPluginCocoa.bundle <<< No JavaAppletPlugin.plugin! $ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)
$ sw_vers
ProductName: Mac OS X
ProductVersion:
10.6.8*
BuildVersion: 10K549