0

Currently using IntelliJ for an IDE.

I inherited a project, and when I went through to make an artifact, I think the compiler is including my local JDK in the build, meaning that if my JRE and JDK are not the same, the program fails on a java.long.SecurityException because a quick signature check of the versions is run when my bundled "artifact" (the jar) runs.

Does anyone know how to make an artifact not bind to a specific JDK/JRE at build time? This program needs to be end user agnostic/independent.

Any help appreciated and thanks folks.

Here is the exact exception found when running the jar file:

    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 java.base/sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
        at java.base/sun.security.util.SignatureFileVerifier.process(Unknown Source)
        at java.base/java.util.jar.JarVerifier.processEntry(Unknown Source)
        at java.base/java.util.jar.JarVerifier.update(Unknown Source)
        at java.base/java.util.jar.JarFile.initializeVerifier(Unknown Source)
        at java.base/java.util.jar.JarFile.getInputStream(Unknown Source)
        at java.base/jdk.internal.loader.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
        at java.base/jdk.internal.loader.Resource.cachedInputStream(Unknown Source)
        at java.base/jdk.internal.loader.Resource.getByteBuffer(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Unknown Source)
        at java.base/sun.launcher.LauncherHelper.loadMainClass(Unknown Source)
        at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
gnu_byte
  • 41
  • 1
  • 5
  • IDE build only includes in the jar the libraries you specified in the [artifact configuration](https://www.jetbrains.com/help/idea/working-with-artifacts.html), when [creating a jar](https://www.jetbrains.com/help/idea/creating-and-running-your-first-java-application.html#package) there are 2 options to include dependencies: link via manifest or extract them to a single final jar. The stack trace you see is thrown by the java you use for runtime (JDK 9). You can set the java to run the application under in Run/Configuration. – Andrey Apr 24 '18 at 15:25
  • The error might not be related to different runtimes. Check this thread https://stackoverflow.com/a/999522/2000323 about similar error. – Andrey Apr 24 '18 at 15:25

0 Answers0