Home > Java > javaTutorial > How to Fix 'Invalid signature file digest for Manifest main attributes' Error When Running JAR Files?

How to Fix 'Invalid signature file digest for Manifest main attributes' Error When Running JAR Files?

Barbara Streisand
Release: 2024-12-19 03:20:09
Original
187 people have browsed it

How to Fix

Invalid Signature File Error When Executing JAR Files

Encountering the "Invalid signature file digest for Manifest main attributes" error when executing JAR files can be perplexing. This error often arises due to issues related to signature files, which are utilized to verify the integrity and authenticity of JAR archives.

In the presented case, the issue pertains to the usage of an external library, bouncy castle, within a custom JAR file. While the compilation succeeds, executing the JAR results in the aforementioned error.

One potential solution lies in excluding signature files during the creation of the JAR. This can be achieved by adding specific filter elements to the Maven shade plugin configuration. These elements exclude signature files from the manifest, effectively preventing the error from occurring.

To implement this solution, add the following lines within the plugin configuration:

<configuration>
    <filters>
        <filter>
            <artifact>*:*</artifact>
            <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
            </excludes>
        </filter>
    </filters>
    <!-- Additional configuration. -->
</configuration>
Copy after login

By excluding these signature files, the error should be resolved, allowing the JAR file to execute successfully without issues related to signature verification.

The above is the detailed content of How to Fix 'Invalid signature file digest for Manifest main attributes' Error When Running JAR Files?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template