public static boolean isJavaAtLeast(double version) {
        String javaVersion = System.getProperty("java.version");
        if (javaVersion == null) {
            return false;
        }

        // if the retrieved version is one three digits, remove the last one.
        Matcher matcher = JAVA_VERSION.matcher(javaVersion);
        if (matcher.matches()) {
            javaVersion = matcher.group(1);
        }

        try {
            double v = Double.parseDouble(javaVersion);
            return v >= version;
        } catch (NumberFormatException e) { //NOSONAR if it's not a number, just return false
            return false;
        }
    }
public static boolean isJavaAtLeast ( double version ) { String javaVersion = System . getProperty ( "java.version" ) ; if ( javaVersion == null ) { return false ; } Matcher matcher = JAVA_VERSION . matcher ( javaVersion ) ; if ( matcher . matches ( ) ) { javaVersion = matcher . group ( 1 ) ; } try { double v = Double . parseDouble ( javaVersion ) ; return v >= version ; } catch ( NumberFormatException e ) { return false ; } }
Checks whether the current JAva runtime has a version equal or higher then the given one. As Java version are
not double (because they can use more digits such as 1.8.0), this method extracts the two first digits and
transforms it as a double.
@param version the version
@return {@literal true} if the current Java runtime is at least the specified one,
{@literal false} if not or if the current version cannot be retrieve or is the retrieved version cannot be
parsed as a double.