code: public static String getJavaTargetVersionFromPom() {
          try {
              Properties properties = new Properties();
              ClassLoader classLoader = ClassLoader.getSystemClassLoader();
              properties.load(classLoader.getResourceAsStream("project.properties"));
              return "" + properties.getProperty("targetJavaVersion");
          } catch (Exception ex) {
              return "";
          }
      }
docs: getJavaTargetVersionFromPom, Returns a string with the java "target" version, as it was
  specified in the pom file at compile time.