InstallationCheck: How to check if Java 6 is installed on 10.5?
InstallationCheck: How to check if Java 6 is installed on 10.5?
- Subject: InstallationCheck: How to check if Java 6 is installed on 10.5?
- From: Xochitl Lunde <email@hidden>
- Date: Wed, 26 May 2010 16:18:40 -0500
I am trying to check the Java version
in my InstallationCheck script. So far, I have found 2 ways to do
this, by running "java -version" in the script, and by checking
the /System/Library/CoreServices/JavaVersion.plist file, if present. Not
all systems have the file present if they haven't run any Java updates
yet, and I don't know how much I can count on the file being there in the
future. So I mainly test it to see if I can present a more useful
error message to the user.
I need to support Mac OS 10.5 &
10.6 with 64-bit Intel JVM 1.6 or newer.
I find that my script fails on Leopard
when doing a command line or ARD install. The problem seems to be
that the 'root' user is still running java 1.5, even when the 64-bit 1.6
is installed.
I need to fix it so the script will
succeed in a command line installation if Java 1.6 is installed. What
is the right way to check if Java 6 is installed? I am getting my
error string #21 when doing a command line installation on Leopard using
'sudo' or if I use ARD to remote install. The second check for the
java-version on the command line works fine for GUI installation, and will
even error out if Java 6 is not enabled for that user.
What I maybe want to do is... instead
of erroring out with string 21, if I am the root user on OSX 10.5, then
I want to check if Java 6 is 'installed' on this machine, since it won't
be the version that runs when I'm root to test against.
------------------------------------------------------------------------------------------------------
InstallationCheck.strings
------------------------------------------------------------------------------------------------------
"16" = "Too many users
are logged in. PowerAlert cannot be installed correctly for all users
when multiple users are logged in." ;
"17" = "PowerAlert requires
Java Update 1 for Mac OS X 10.6.2" ;
"18" = "PowerAlert requires
Java Update 6 for Mac OS X 10.5.8" ;
"19" = "PowerAlert requires
a 64-bit Intel processor. This processor is not an Intel processor."
;
"20" = "PowerAlert requires
a 64-bit Intel processor. This Intel processor is not 64-bit."
;
"21" = "PowerAlert requires
64-bit Java SE 6. Please install and enable 64-bit Java SE 6 for
Applications." ;
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
Partial InstallationCheck
------------------------------------------------------------------------------------------------------
# Make sure the system is at least 10.5.8
or 10.6.2.
# Actually we won't do this, but the
Java check will make sure we have 10.5 or 10.6 also.
# The Java Updates force the user to
have the correct patch level, and if Apple releases
# Java 6 for earlier versions of 10.5,
then PowerAlert should work fine.
# Make sure the system is updated to
Java Update 1 on 10.6 or Java Update 6 on 10.5.
if [ -f "/System/Library/CoreServices/JavaVersion.plist"
] ; then
java_update="`grep
-e "Update" < /System/Library/CoreServices/JavaVersion.plist
| awk {'print $2'} | awk -F "<" {'print $1'}`"
echo
"Java Update version is '${java_update}'."
if
[ ! -z "`grep -e "Java For Mac OS X 10.6" < /System/Library/CoreServices/JavaVersion.plist`"
] ; then
if [ $java_update -lt 1 ] ; then
echo "You
need at least Java Update 1 for Mac OS X 10.6.2"
exit 113;
# Return string 17.
fi
elif
[ ! -z "`grep -e "Java For Mac OS X 10.5" < /System/Library/CoreServices/JavaVersion.plist`"
] ; then
if [ $java_update -lt 6 ] ; then
echo "You
need at least Java Update 6 for Mac OS X 10.5.8"
exit 114;
# Return string 18.
fi
fi
fi
# Make sure the Java we want is enabled
too. I don't have a big
# variety of systems to test against
yet, so let's be cautious.
# This check needs to work incase the
user doesn't have the
# Java update file and has < Java
update 1 for 10.5.8 or such.
java_version="`java -version 2>&1
| awk {'print $3'} | head -n 1`"
java_stripped_version="`echo ${java_version}
| awk -F [\\"] {'print $2'}`"
java_major="`echo ${java_stripped_version}
| awk -F . {'print $1'}`"
java_minor="`echo ${java_stripped_version}
| awk -F . {'print $2'}`"
java_rev="`echo ${java_stripped_version}
| awk -F . {'print $3'}`"
if [ "${java_major}" -lt "2"
] ; then
echo
"Java major version '${java_major}' is less than '2'."
if
[ "${java_minor}" -lt "6" ] ; then
echo "Java minor version '${java_minor}'
is less than '6'."
echo "PowerAlert requires Java version
1.6."
exit 117 ; # Return string 21.
else
echo "Java minor version '${java_minor}'
is acceptable."
fi
fi
exit 0 ; _______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden