
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-05-2014 02:24 PM
Hey guys,
I was updating my image recently and I decided to move to Java Runtime 7. I noticed that after I started using this, the Extension Attribute stops working, or rather it reports as not installed even though it is.
This is the EA that I'm using:
#!/bin/sh
#Check if java_home is defined
javaHome=`/usr/libexec/java_home 2> /dev/null`;
if [ ! -z $javaHome ]
then
vers=`java -version 2>&1 | grep "java version" | awk '{print substr($3,2,length($3)-2);}'`
echo "<result>$vers</result>"
else
echo "<result>Not Installed</result>"
fi
I think I know what the problem is, I just don't know how to fix it.
It seems that when it tries to run "java -version" from terminal it fails because we don't install the JDK. (If I go to terminal and type "java -version" it attempts to give the site to install the JDK).
We would rather not install the JDK as well, unless necessary.
Anyone have any thoughts?
Sincerely,
TJ
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-05-2014 02:32 PM
I've seen this as well recently on a Mac that did not have the JDK installed. Only thing I can recommend is changing the Extension Attribute to pull the version string from the Info.plist for the Internet Plug-In
#!/bin/sh
#Check if java_home is defined
javaHome=`/usr/libexec/java_home 2> /dev/null`;
if [ ! -z $javaHome ]
then
vers=`defaults read /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist CFBundleVersion`
echo "<result>$vers</result>"
else
echo "<result>Not Installed</result>"
fi
Note that the above will return something like:
1.7.60.19
If you change CFBundleVerison to CFBundleShortVersionString, you get a more human readable:
Java 7 Update 60
Choice is yours on which to use. The former will be closer to what the java -version command was previously pulling, but not actually the same thing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-05-2014 02:32 PM
I've seen this as well recently on a Mac that did not have the JDK installed. Only thing I can recommend is changing the Extension Attribute to pull the version string from the Info.plist for the Internet Plug-In
#!/bin/sh
#Check if java_home is defined
javaHome=`/usr/libexec/java_home 2> /dev/null`;
if [ ! -z $javaHome ]
then
vers=`defaults read /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist CFBundleVersion`
echo "<result>$vers</result>"
else
echo "<result>Not Installed</result>"
fi
Note that the above will return something like:
1.7.60.19
If you change CFBundleVerison to CFBundleShortVersionString, you get a more human readable:
Java 7 Update 60
Choice is yours on which to use. The former will be closer to what the java -version command was previously pulling, but not actually the same thing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-05-2014 02:36 PM
Brilliant!
Thank you so much! This was what I was going to try to do after brainstorming for a bit.
Much appreciated, sir.
Cheers!
