def _locate(self, minimum_version=None, maximum_version=None, jdk=False):
    """Finds a java distribution that meets any given constraints and returns it.

    :param minimum_version: minimum jvm version to look for (eg, 1.7).
    :param maximum_version: maximum jvm version to look for (eg, 1.7.9999).
    :param bool jdk: whether the found java distribution is required to have a jdk.
    :return: the located Distribution.
    :rtype: :class:`Distribution`
    :raises: :class:`Distribution.Error` if no suitable java distribution could be found.
    """
    for location in itertools.chain(self._distribution_environment.jvm_locations):
      try:
        dist = Distribution(home_path=location.home_path,
                            bin_path=location.bin_path,
                            minimum_version=minimum_version,
                            maximum_version=maximum_version,
                            jdk=jdk)
        dist.validate()
        logger.debug('Located {} for constraints: minimum_version {}, maximum_version {}, jdk {}'
                     .format(dist, minimum_version, maximum_version, jdk))
        return dist
      except (ValueError, Distribution.Error) as e:
        logger.debug('{} is not a valid distribution because: {}'
                     .format(location.home_path, str(e)))
        pass

    if (minimum_version is not None
        and maximum_version is not None
        and maximum_version < minimum_version):
      error_format = ('Pants configuration/options led to impossible constraints for {} '
                      'distribution: minimum_version {}, maximum_version {}')
    else:
      error_format = ('Failed to locate a {} distribution with minimum_version {}, '
                      'maximum_version {}')
    raise self.Error(error_format.format('JDK' if jdk else 'JRE', minimum_version, maximum_version))
Finds a java distribution that meets any given constraints and returns it.

    :param minimum_version: minimum jvm version to look for (eg, 1.7).
    :param maximum_version: maximum jvm version to look for (eg, 1.7.9999).
    :param bool jdk: whether the found java distribution is required to have a jdk.
    :return: the located Distribution.
    :rtype: :class:`Distribution`
    :raises: :class:`Distribution.Error` if no suitable java distribution could be found.