code: private static int getJavaVersion() {
  		String version = System.getProperty("java.version");
  		if (version == null) {
  			return -1;
  		} else {
  			int index = version.indexOf('.');
  			if (index > 0) {
  				version = version.substring(0, index);
  			}
  
  			try {
  				return Integer.parseInt(version);
  			} catch (NumberFormatException ex) {
  				return -1;
  			}
  		}
  	}
docs: Gets the major version number of Java.
  
  @return Major version number of Java or -1 if unknown