"Invalid signature file" when attempting to run a .jar
My java program is packaged in a jar file and makes use of an external jar library, bouncy castle. My code compiles fine, but running the jar leads to the following error:
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
I've googled for over an hour searching for an explanation and found very little of value. If anyone has seen this error before and could offer some help, I would be obliged.
The solution listed here might provide a pointer.
Invalid signature file digest for Manifest main attributes
Bottom line :
It's probably best to keep the official jar as is and just add it as a dependency in the manifest file for your application jar file.
对于那些在尝试使用maven-shade-plugin
创建超级jar时出现此错误的解决方案是,通过将以maven-shade-plugin
添加到插件配置来排除清单签名文件:
<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>
对于那些使用gradle并试图创建和使用胖jar的人来说,下面的语法可能会有所帮助。
jar {
doFirst {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
链接地址: http://www.djcxy.com/p/55014.html
上一篇: 如何运行JAR文件
下一篇: 试图运行.jar时出现“签名文件无效”