def METHOD_NAME():
    if "JAVA_HOME" in os.environ:
        yield os.environ["JAVA_HOME"]
    java_bin = shutil.which("java")
    if java_bin:
        java_bin = os.path.realpath(java_bin)
        yield os.path.join(os.path.dirname(java_bin), "..")
        yield os.path.join(os.path.dirname(java_bin), "..", "jre")
    if is_win:
        import winreg
        java_key_paths = (
            'SOFTWARE\\JavaSoft\\JRE',
            'SOFTWARE\\JavaSoft\\Java Runtime Environment',
            'SOFTWARE\\JavaSoft\\JDK'
        )
        for java_key_path in java_key_paths:
            try:
                kjava = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, java_key_path)
                kjava_values = dict([winreg.EnumValue(kjava, i)[:2]
                                     for i in range(winreg.QueryInfoKey(kjava)[1])])
                current_version = kjava_values['CurrentVersion']
                looking_for = java_key_path + '\\' + current_version
                kjava_current = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, looking_for)
                kjava_current_values = dict([winreg.EnumValue(kjava_current, i)[:2]
                                             for i in range(winreg.QueryInfoKey(kjava_current)[1])])
                yield kjava_current_values['JavaHome']
            except WindowsError as e:
                if e.errno == 2:
                    continue
                else:
                    raise
    if is_mac:
        try:
            result = subprocess.check_output(["/usr/libexec/java_home"])
            yield result.strip().decode("utf-8")
        except subprocess.CalledProcessError:
            yield "/System/Library/Frameworks/JavaVM.framework/Home"