Skip to main content
Solved

Collect Java version - Inventory - Extension Attribute


Did this topic help you find an answer to your question?
Show first post

34 replies

dpertschi
Forum|alt.badge.img+19
  • Contributor
  • 459 replies
  • January 22, 2014
#!/bin/bash
echo "<result>`/usr/bin/java -version 2>&1 > /dev/null | awk '/version/ {gsub(/[""]/,""); print $NF}'`</result>"

ImAMacGuy
Forum|alt.badge.img+23
  • Esteemed Contributor
  • 1310 replies
  • January 22, 2014

that just reported

1.7.0_51

Which is what I am running into


Forum|alt.badge.img+10
  • Contributor
  • 161 replies
  • January 22, 2014

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.


Forum|alt.badge.img+18
  • Valued Contributor
  • 1007 replies
  • January 22, 2014

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"


Forum|alt.badge.img+18
  • Valued Contributor
  • 1007 replies
  • January 22, 2014

sorry 1.6.0 in the first sentence should be 1.7.0


ImAMacGuy
Forum|alt.badge.img+23
  • Esteemed Contributor
  • 1310 replies
  • January 22, 2014

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?


Forum|alt.badge.img+13
  • Contributor
  • 400 replies
  • January 22, 2014

@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.


Forum|alt.badge.img+8
  • Contributor
  • 47 replies
  • March 14, 2014

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?


Forum|alt.badge.img+21
  • Contributor
  • 1028 replies
  • March 17, 2014

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings