Skip to main content
Solved

Java Runtime 7 update 60 issue with Extension Attribute


Forum|alt.badge.img+14

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

Best answer by mm2270

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.

View original
Did this topic help you find an answer to your question?

2 replies

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • Answer
  • June 5, 2014

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.


Forum|alt.badge.img+14
  • Author
  • Valued Contributor
  • 156 replies
  • June 5, 2014

Brilliant!

Thank you so much! This was what I was going to try to do after brainstorming for a bit.

Much appreciated, sir.

Cheers!


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