Reading the manifest from a JAR file

Create a JarFile instance and call the method getManifest. You’ll have access to all the Manifest’s attributes.

Main.java:

import java.util.jar.*;
import java.util.*;
import java.io.*;
 
public class Main
{
   public static void main(String []args) throws IOException {
      JarFile jar = new JarFile("Main.jar");
      Manifest manifest = jar.getManifest();
 
      // now you can interrogate/modify the manifest file
      Attributes attributes = manifest.getMainAttributes();
      String st = (String) attributes.get(new Attributes.Name("Specification-Title"));
      System.out.println(st);           
   }
}