MINIMUM_MAJOR_VERSION=$1
MINIMUM_MINOR_VERSION=$2

java -version 2> java_ver.tmp
VERSION=`cat java_ver.tmp | grep "java version" | awk '{ print substr($3, 2, length($3)-2); }'`
rm java_ver.tmp

if [ ${#VERSION} -eq 0 ]
then
  exit 1
fi

INSTALLED_MAJOR_VERSION=`echo $VERSION | sed -e 's/\.[0-9\._]*//g'`
INSTALLED_MINOR_VERSION=`echo $VERSION | sed -e 's/.[0-9_]*$//g' | sed -e 's/^[0-9]*\.//g'`

COMPATIBLE_JAVA_FOUND=0
if [ "$INSTALLED_MAJOR_VERSION" -gt "$MINIMUM_MAJOR_VERSION" ]
then
  COMPATIBLE_JAVA_FOUND=1
elif [ $INSTALLED_MAJOR_VERSION -eq $MINIMUM_MAJOR_VERSION ]
then
  if [ $INSTALLED_MINOR_VERSION -ge $MINIMUM_MINOR_VERSION ]
  then
    COMPATIBLE_JAVA_FOUND=1
  fi
fi

if [ "$COMPATIBLE_JAVA_FOUND" -eq "1" ]
then
  exit 2
else
  exit 1
fi
