2016-04-28 70 views
3

我有一個運行在命令行中的項目,在IntelliJ中運行它時可以正常工作。然而,當我建立.jar和命令行我碰到下面的錯誤運行:使用IntelliJ構建.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) 

我試圖運行使用命令Java的罐子JarName.jar

乾杯罐子。

+0

這是由於簽署的依賴。當您構建JAR文件時,解析簽名的依賴關係會導致此問題。請檢查這個答案: http://stackoverflow.com/questions/41746177/how-do-i-create-a-runnable-jar-in-intellij-as-i-would-in-eclipse/43855741#43855741 – 2017-05-16 09:52:12

回答

2

你可以運行 - >編輯配置,並檢查是否有任何VM選項,程序參數或Env變量?如果使用命令行運行它,則可能需要傳遞這些參數。

我發現另一篇文章,這可能有助於 「Invalid signature file」 when attempting to run a .jar

+0

謝謝你的回覆,我看了看,沒有看到任何這些。我會看看你發佈的鏈接,看看它是否修復它 – Cypher236

+0

我設法修復它通過你鏈接的線程上的回覆解讀!非常感謝 – Cypher236