Sobes.tech
Junior

What can you tell about the JAR file manifest?

sobes.tech AI

Answer from AI

The manifest file (META-INF/MANIFEST.MF) in a JAR file is a special file containing metadata about the contents of the JAR archive.

It is used for:

  • Specifying the entry point: Indicating the main class to launch the executable JAR (Main-Class).
  • Managing versions: Storing information about the application or library version (Implementation-Version, Specification-Version).
  • Defining class search paths: Indicating dependencies and directories for class searching (Class-Path).
  • Digital signatures: Contains signature information for integrity and source verification of the JAR (Signer-Information, Digest).
  • Extending functionality: Using special attributes for various frameworks and technologies (e.g., OSGi Bundle-ManifestVersion).

File structure:

Manifest-Version: 1.0
Created-By: 1.8.0 (Oracle Corporation)
Main-Class: com.example.MyApp
Class-Path: lib/dependency1.jar lib/dependency2.jar

The standard attribute Manifest-Version indicates the version of the manifest specification. Created-By indicates the Java environment version that created the archive.

Most tools (such as Maven, Gradle, Ant) automatically create or update this file during JAR file assembly. It can also be created or modified manually.