question: public static int parseMajorJavaVersion ( String version ) { String jvmVersion = version ; if ( jvmVersion . startsWith ( "1." ) ) { jvmVersion = jvmVersion . substring ( 2 ) ; } int separator = jvmVersion . indexOf ( '.' ) ; if ( separator > 0 ) { jvmVersion = jvmVersion . substring ( 0 , separator ) ; } separator = jvmVersion . indexOf ( '-' ) ; if ( separator > 0 ) { jvmVersion = jvmVersion . substring ( 0 , separator ) ; } return Integer . parseInt ( jvmVersion ) ; }
target:  Parse major Java version from a Java version string.