code: public static Manifest getManifestWithMainClass(Class<?> klass) {
      Manifest manifest = new Manifest();
      manifest.getMainAttributes().put(ManifestFields.MANIFEST_VERSION, "1.0");
      manifest.getMainAttributes().put(ManifestFields.MAIN_CLASS, klass.getName());
      return manifest;
    }
docs: Given a class generates a manifest file with main-class as class.
  
  @param klass to set as Main-Class in manifest file.
  @return An instance {@link java.util.jar.Manifest}