Search code examples
javaintellij-ideajarjava-native-interface

Generated JAR file - JNI error has occurred


I am using the IntelliJ IDEA to create a jar artifact from a LeanFT project.

The jar artifact was generated, but with the following error message:

JNI error has occurred, please check your installation and try again

when trying to execute the jar file directly.

It is working when I use the IDE for execution. No arguments or parameter values are required. I am getting the same error when I generate a jar file from a simple "Hello World".

Stack trace:

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)

Solution

  • I looked into the exception you got : Invalid signature file digest for Manifest main attributes.

    Are you using signed jar files as dependencies of your project? If so, when you generate a jar containing the dependencies, then try to execute it - the JVM detects your generated jar as a manipulation of the signed jars you are using.

    Here is a list of questions where this exception was encountered:

    Follow the links above and find the exact solution which will help you. The solution depends on what exactly you are doing, deployment-wise (specifics of how you are creating your jar artifact).