{"id":7319,"library":"java-manifest","title":"Java Manifest File Parser","description":"The `java-manifest` library provides functionality to encode and decode Java's `META-INF/MANIFEST.MF` files using Python. It represents a manifest as a list of dictionaries, where each dictionary corresponds to a section within the manifest. The library is currently at version 1.1.0, with its last release in July 2020, indicating a low release cadence.","status":"maintenance","version":"1.1.0","language":"en","source_language":"en","source_url":"https://github.com/elihunter173/java-manifest-py","tags":["java","manifest","parsing","jar","metadata","encoding","decoding"],"install":[{"cmd":"pip install java-manifest","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary module is imported as `java_manifest`, and its functions are then accessed via `java_manifest.loads()`, `java_manifest.dumps()`, etc.","symbol":"java_manifest","correct":"import java_manifest"}],"quickstart":{"code":"import java_manifest\n\nmanifest_str = \"\"\"Manifest-Version: 1.0\nCreated-By: My Build Tool\nApplication-Name: ExampleApp\n\nName: com/example/app/MainClass.class\nMD5-Digest: AB12CD34EF56GH78IJ90KL12MN34OP56\n\"\"\"\n\n# Load manifest from a string\nmanifest_data = java_manifest.loads(manifest_str)\nprint(\"Loaded Manifest Data:\")\nfor section in manifest_data:\n    print(section)\n\n# Add a new attribute to the first section\nif manifest_data:\n    manifest_data[0][\"New-Attribute\"] = \"SomeValue\"\n\n# Dump manifest back to a string\nupdated_manifest_str = java_manifest.dumps(manifest_data)\nprint(\"\\nUpdated Manifest String:\")\nprint(updated_manifest_str)","lang":"python","description":"Demonstrates loading a Java manifest string into a Python list of dictionaries, modifying it, and then dumping it back to a manifest-formatted string."},"warnings":[{"fix":"Always ensure your manifest strings or files terminate with a newline character (e.g., `\"Key: Value\\n\"` for a single line, or a final `\\n` after the last entry for multi-line manifests).","message":"Java manifest files, by specification, must end with a newline character. If the input manifest string or file lacks a trailing newline, the last attribute-value pair might be silently dropped or parsed incorrectly by this library or Java tools.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For complex or non-string values, provide custom `encoder` and `decoder` functions to `java_manifest.dumps()` and `java_manifest.loads()` respectively, to convert between Python objects and string representations as needed. The default behavior expects string or boolean values.","message":"The Java manifest format strictly treats all attribute values as strings. While the library supports `str` and `bool` values in the Python representation, attempting to dump manifests with other structured data types (e.g., lists, dictionaries, integers) for values will fail without custom handling.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure that the manifest string or file you are processing or creating explicitly ends with a newline character (`\\n`).","cause":"The input manifest string or file does not end with a newline character, which is required by the Java manifest specification for proper parsing of the final entry.","error":"The last line of my manifest data is missing or incorrectly parsed after loading."},{"fix":"Before dumping, convert all non-string/non-boolean values in your manifest data (list of dictionaries) to their string representations, or provide a custom `encoder` function to `java_manifest.dumps()` that handles the specific data types you are using.","cause":"You are attempting to dump a manifest where a value in one of the dictionary sections is not a `str` or `bool` type, and no custom `encoder` function has been provided to handle the conversion. The `java-manifest` library expects attribute values to be strings or booleans.","error":"TypeError: ... object is not iterable (or similar type error) when dumping data."}]}