code: static int getMajorVersion(String javaSpecVersion) {
          try {
              if (javaSpecVersion.contains(".")) { //before jdk 9
                  return Integer.parseInt(javaSpecVersion.split("\\.")[1]);
              } else {
                  return Integer.parseInt(javaSpecVersion);
              }
          } catch (NumberFormatException e ){
              throw getUnableToParseVersionException(javaSpecVersion);
          }
      }
docs: Only used for testing. Use {@link #getMajorVersion()} instead. Checkout http://openjdk.java.net/jeps/223 for more information
  @param javaSpecVersion System.getProperty("java.specification.version")
  @return the current major Java version.