IntelliJ Jar Error : Invalid signature file digest for Manifest main attributes
IntelliJ Jar Error : Invalid signature file digest for Manifest main attributes
我在 armx64 linux-based
系统上使用 IntelliJ
IDE,我在 non-maven java 有很多模块(依赖项)链接到它的项目。当 运行 从 IDE 连接我的项目时,一切正常,但是当将它构建到 运行nable jar 文件并尝试从终端 运行 jar 时,使用 java -jar myjar.jar
,我收到以下错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
at java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
at sun.misc.URLClassPath$JarLoader.getInputStream(URLClassPath.java:977)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:454)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
我目前正在使用 OpenJdk-1.8,我尝试使用 Oracle JDK v1.8 来构建然后重新运行 jar 文件,但仍然面临同样的错误。我还尝试创建一个新的简单 "Hello world" 应用程序并为其导出相应的 jar,它 运行 成功且没有错误。
这里是我的jar内部结构和对应的manifist文件:
jar structure screenshot
感谢 @y.bedrov 链接到此 帮助我解决了错误,其中它包括以下内容:
"sqljdbc4.jar" was the signed JAR in OP's external libraries. So,
following above approach to systematically exclude the signature
related files like .SF, .RSA or .DES or other algorithms files is the
right way to move forward.
是的,我也在使用 "sqljdbc4.jar",所以在阅读答案后,我决定通过从我的 jar 文件中的 Meta-inf 文件夹中删除签名文件来解决问题。
我在 armx64 linux-based
系统上使用 IntelliJ
IDE,我在 non-maven java 有很多模块(依赖项)链接到它的项目。当 运行 从 IDE 连接我的项目时,一切正常,但是当将它构建到 运行nable jar 文件并尝试从终端 运行 jar 时,使用 java -jar myjar.jar
,我收到以下错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
at java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
at sun.misc.URLClassPath$JarLoader.getInputStream(URLClassPath.java:977)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:454)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
我目前正在使用 OpenJdk-1.8,我尝试使用 Oracle JDK v1.8 来构建然后重新运行 jar 文件,但仍然面临同样的错误。我还尝试创建一个新的简单 "Hello world" 应用程序并为其导出相应的 jar,它 运行 成功且没有错误。
这里是我的jar内部结构和对应的manifist文件: jar structure screenshot
感谢 @y.bedrov 链接到此
"sqljdbc4.jar" was the signed JAR in OP's external libraries. So, following above approach to systematically exclude the signature related files like .SF, .RSA or .DES or other algorithms files is the right way to move forward.
是的,我也在使用 "sqljdbc4.jar",所以在阅读答案后,我决定通过从我的 jar 文件中的 Meta-inf 文件夹中删除签名文件来解决问题。