--- a/m4/ax_jni_include_dir.m4
+++ b/m4/ax_jni_include_dir.m4
@@ -73,13 +73,19 @@ fi
 
 case "$host_os" in
         darwin*)        # Apple Java headers are inside the Xcode bundle.
-            macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p')
-            if @<:@ "$macos_version" -gt "7" @:>@; then
-                _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
-                _JINC="$_JTOPDIR/Headers"
+            major_macos_version=$(sw_vers -productVersion | sed -n -e 's/^\(@<:@0-9@:>@*\).@<:@0-9@:>@*.@<:@0-9@:>@*/\1/p')
+            if @<:@ "$major_macos_version" -gt "10" @:>@; then
+                _JTOPDIR="$(/usr/libexec/java_home)"
+                _JINC="$_JTOPDIR/include"
             else
-                _JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
-                _JINC="$_JTOPDIR/Headers"
+                macos_version=$(sw_vers -productVersion | sed -n -e 's/^@<:@0-9@:>@*.\(@<:@0-9@:>@*\).@<:@0-9@:>@*/\1/p')
+                if @<:@ "$macos_version" -gt "7" @:>@; then
+                    _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
+                    _JINC="$_JTOPDIR/Headers"
+                else
+                    _JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
+                    _JINC="$_JTOPDIR/Headers"
+                fi
             fi
             ;;
         *) _JINC="$_JTOPDIR/include";;
