我使用Intellij IDEA 15创建了gradle
java项目:
然后在我的build.gradle
我已将这行代码添加到dependencies
以便使用其他JAR文件
compile fileTree(dir: 'libs', include: '*.jar')
然后我打开Artifcats设置并使用Main类设置我的Manifest File位置:
My Manifest文件包含以下内容:
Manifest-Version: 1.0
Main-Class: kz.ant.signer.Main
我的主要课程在我的Hello world
方法
private static main
功能
然后我生成我的JAR文件并尝试通过控制台启动它。它向我显示了这条消息:
no main manifest attribute, in signer.jar
然后我用archiver打开这个JAR文件并手动编写我的Main类以启动它。
然后它向我抛出了这个错误:
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)
我认为这是因为Manifest文件夹中有*.RSA
和*.DSA
个文件,所以我在build.gradle
中添加了这些代码行:
jar {
doFirst {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
然而,这并没有改变任何事情。还有这些签名文件。
请问解决这个问题?