code: public static String getApplicationVersionFromJar(Class<?> _class, String _default) {
          try {
              Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF");
              while (resources.hasMoreElements()) {
  
                  Manifest manifest = new Manifest(resources.nextElement().openStream());
                  Attributes attribs = manifest.getMainAttributes();
                  String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
                  if (ver == null) {
                  	return _default;
                  }
  
                  String rev = attribs.getValue("Implementation-Revision");
                  if (rev != null) {
                      ver += "-r" + rev;
                  }
                  return ver;
  
              }
          } catch (IOException _ex) {
          }
  
          return _default;
      }
docs: Read the JARs manifest and try to get the current program version from it.
  @param _class class to use as entry point
  @param _default default string to use if version could not be found
  @return version or null