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);
}

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 ) ; }
parse major java version from a java version string .
