Article Directory
Blog summary: The core error message is as follows:
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
The signature file in the jar package is invalid, just delete the signature file in the META-INF directory;
open the compressed package, delete these two signature files;
1. Error message
When processing dependent libraries, choose to package the dependent libraries into a Jar package, the configuration is as follows:
If you use the second method, only the core main program code will be packaged when packaging, and the dependent library will be copied to the same level directory;
If so, when copying the program to another directory, you need to copy the dependent library separately, which is cumbersome;
This is to use the second method, the output jar package, to independently manage a bunch of jar packages;
The required dependent libraries are all in the "Extracted 'xxx'" on the left, so that the dependent libraries can be packaged into the jar package;
The effect after packaging is the following style, a bunch of package name files;
Executing the above jar program will report an error;
Full error message:
D:\>java -jar App.main2.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(Unknown Source)
at sun.security.util.SignatureFileVerifier.process(Unknown Source)
at java.util.jar.JarVerifier.processEntry(Unknown Source)
at java.util.jar.JarVerifier.update(Unknown Source)
at java.util.jar.JarFile.initializeVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
at sun.misc.Resource.cachedInputStream(Unknown Source)
at sun.misc.Resource.getByteBuffer(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Two, the solution
Core error message:
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
Error: A JNI error has occurred, please check your installation and try again
java.lang.SecurityException: Invalid signature file digest for Manifest main attribute
The error message is obvious, which means that the META-INF information signature file in the jar package is invalid;
If the signature file is invalid, delete the two signature files directly without using the signature file;
Use a compression tool to open, here I use the 7-zip compression tool to open the jar package, delete the two signature files MANIFEST.MF and MSFTSIG.RSA;
Then execute the program again, the program can run normally;