public static String getMacOsMajorVersion() {
        if (!isMacOs()) {
            return null;
        }

        String osVersion = System.getProperty("os.version");

        if (osVersion != null) {
            String[] split = osVersion.split("\\.");
            if (split.length >= 2) {
                return split[0] + "." + split[1];
            } else {
                return osVersion;
            }
        }

        return null;
    }
public static String getMacOsMajorVersion ( ) { if ( ! isMacOs ( ) ) { return null ; } String osVersion = System . getProperty ( "os.version" ) ; if ( osVersion != null ) { String [ ] split = osVersion . split ( "\\." ) ; if ( split . length >= 2 ) { return split [ 0 ] + "." + split [ 1 ] ; } else { return osVersion ; } } return null ; }
Tries to get the current version of MacOS/MacOS X.
The version usually looks like '10.13.4', where the part behind the last dot represents the patchlevel.
The major version in this case would be '10.13'.
@return version without patchlevel or null