#
# This checks for the presence of Java.
#
JAVAPRESENT=0
CLASSES="none"

NOJAVA_MSG="No compatible version of Java is installed."

#
# This returns the list of installed package instances of the provided
# package.
#
getpkginsts() { # $1 is the pkg
    l=`/usr/bin/pkginfo ${1}.* 2> /dev/null`
    if [ -n "${l}" ]; then
	echo "${l}" | /usr/bin/nawk ' { print $2;  } '
    else
	echo ""
    fi
}

pkginsts=`getpkginsts SUNWj2rt`
if [ -n "$pkginsts" ]; then
	if [ -d /usr/java1.2/jre ]; then
		JAVAPRESENT=1
		CLASSES="${CLASSES} j2link"
	fi
fi

pkginsts=`getpkginsts SUNWj3rt`
if [ -n "$pkginsts" ]; then
	if [ -d /usr/j2se/jre ]; then
		JAVAPRESENT=1
		CLASSES="${CLASSES} j3link"
	fi
fi

if [ ${JAVAPRESENT} -eq 1 ]; then
	echo "CLASSES=${CLASSES}" > $1
	exit 0
else
	echo ${NOJAVA_MSG}
	exit 3
fi
