def find_rt_jar(javahome=None):
    """Find the path to the Java standard library jar.

    The jar is expected to exist at the path 'jre/lib/rt.jar' inside a
    standard Java installation directory. The directory is found using
    the following procedure:

    1. If the javehome argument is provided, use the value as the
       directory.
    2. If the JAVA_HOME environment variable is set, use the value as
       the directory.
    3. Find the location of the ``java`` binary in the current PATH and
       compute the installation directory from this location.

    Args:
        javahome: A path to a Java installation directory (optional).
    """

    if not javahome:
        if 'JAVA_HOME' in os.environ:
            javahome = os.environ['JAVA_HOME']
        elif sys.platform == 'darwin':
            # The default java binary on OS X is not part of a standard Oracle
            # install, so building paths relative to it does not work like it
            # does on other platforms.
            javahome = _find_osx_javahome()
        else:
            javahome = _get_javahome_from_java(_find_java_binary())

    rtpath = os.path.join(javahome, 'jre', 'lib', 'rt.jar')
    if not os.path.isfile(rtpath):
        msg = 'Could not find rt.jar: {} is not a file'.format(rtpath)
        raise ExtensionError(msg)

    return rtpath
Find the path to the Java standard library jar.

    The jar is expected to exist at the path 'jre/lib/rt.jar' inside a
    standard Java installation directory. The directory is found using
    the following procedure:

    1. If the javehome argument is provided, use the value as the
       directory.
    2. If the JAVA_HOME environment variable is set, use the value as
       the directory.
    3. Find the location of the ``java`` binary in the current PATH and
       compute the installation directory from this location.

    Args:
        javahome: A path to a Java installation directory (optional).