Skip to main content

Anyone have a good method or suggestion on how to collect Java version on clients?



My method (which isn't working) was I wrote an extension attribute. But...even though the command works manually on the client, no information is collected in the JSS.



I've verified that the client is executing the Extension Attribute by examining an output file after performing Recon (sudo jamf recon -saveFormTo /pathtofile). I see my other Extension Attributes - and I see that it runs the Java attribute - but no information is being collected.



Here is my attribute:
Data Type: String
Input Type: Populated By Script



#!/bin/sh
echo "<result>java -version</result>"



When run locally (manually) you get this output:
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)



Any ideas on the best way to get the Java version in Inventory? Thanks!



Sean

#!/bin/bash
echo "<result>`/usr/bin/java -version 2>&1 > /dev/null | awk '/version/ {gsub(/[""]/,""); print $NF}'`</result>"

that just reported



1.7.0_51


Which is what I am running into


what do you get when you go into terminal and type: /usr/bin/java -version



Testing on a 10.8.5 machine with both Java 1.7.0_51 (from oracle) and Java 1.6.0_65 (from apple) it returns the 1.6.0_65 info.


you need to realize that the 1.6.0 java from oracle by default is only the SDK part not the internet plugin. they are two separate pieces. Most likely if you have installed what the java.com web page points you to its only the internet plugin. you have to get the 1.7 SDK from elsewhere the plugin pkg is named "Java 7 Update 51.pkg" and the JDK is named "JDK 7 Update 51.pkg"


sorry 1.6.0 in the first sentence should be 1.7.0


Mine returns -

/usr/bin/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode



Is it possible that if JDK 7 is installed, it doens't install Apples?


@jwojda
You have JDK 7 installed and JDK comes with JRE (internet plug-in) as well.
If you want Apple Java 6 (with JDK and JRE), please downland and install the latest Java update from apple (e.g.- Java for OS X 2013-005). Also you will have to uninstall Java 7 JDK and JRE first.


I tried this script s Extension Attribute.
#!/bin/sh
echo "<result>java -version</result>"



I and then update my inventory. when I look in my inventory nothing is showing up for the result of the script. How is the best way to report on java version?


Based on what @rtrouton][/url had already submitted for an extension attribute, I'm submitting this one today that goes a little further and also gets the version. It's always good to look under the Third-Party section of the Nation to see if this stuff exists there. Here's Java's:



https://jamfnation.jamfsoftware.com/viewProduct.html?id=229&view=info



And here's my script I'm submitting below. Use at your own risk and test. As with other extension attributes, if your users have admin rights to their box and you're not stopping them from upgrading things like Flash, Flip4Mac, SilverLight, and Java on your own you can't really base your smart groups on the last installed Casper Package of those installed by you. You really need to use an extension attribute that see what version is really installed and then base smart groups and policies on that. Just my opinion.



#!/bin/sh

# Java_Vendor_and_Version.sh
#
# Original version for vendor by Richard Trouton on 5/8/13.
# Modified to include version by Craig Ernst on 3/17/14.
# Tested on Mac OS X 10.8 and 10.9
#
# Keep in mind that on a clean install of 10.8 the command 'java -version'
# will prompt to install Apples old version of Java SE 6 if not installed,
# and that 'java -version' will not give the true Internet Plug-In version.
# Even after installing an Oracle version of Java that version info is not updated.
#
# Also keep in mind that on 10.9 the command 'java -version' behaves similarly.
# Although instead of a prompt to install Apple's version it will direct you
# to Oracle's website.
#
# If reporting no Java or an Apple version you should consider installing
# an Oracle version as Apple no longer updates Java.
#
#!/bin/bash

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

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

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

Reply