code: public static Manifest getManifest(Location jarLocation) throws IOException {
      URI uri = jarLocation.toURI();
  
      // Small optimization if the location is local
      if ("file".equals(uri.getScheme())) {
        JarFile jarFile = new JarFile(new File(uri));
        try {
          return jarFile.getManifest();
        } finally {
          jarFile.close();
        }
      }
  
      // Otherwise, need to search it with JarInputStream
      JarInputStream is = new JarInputStream(new BufferedInputStream(jarLocation.getInputStream()));
      try {
        // This only looks at the first entry, which if is created with jar util, then it'll be there.
        Manifest manifest = is.getManifest();
        if (manifest != null) {
          return manifest;
        }
  
        // Otherwise, slow path. Need to goes through the entries
        JarEntry jarEntry = is.getNextJarEntry();
        while (jarEntry != null) {
          if (JarFile.MANIFEST_NAME.equals(jarEntry.getName())) {
            return new Manifest(is);
          }
          jarEntry = is.getNextJarEntry();
        }
  
      } finally {
        is.close();
      }
  
      return null;
    }
docs: Load the manifest inside the given jar.
  
  @param jarLocation Location of the jar file.
  @return The manifest inside the jar file or {@code null} if no manifest inside the jar file.
  @throws java.io.IOException if failed to load the manifest.