【发布时间】:2017-03-24 12:23:58
【问题描述】:
下面是我的 ant build jar 目标:
<target name="build jar" depends="compile">
<mkdir dir="${dist.home}" />
<jar destfile="${dist.home}/${app.name}.jar" basedir="${build.home}/classes">
<zipgroupfileset dir="${lib.home}" includes="*.jar" excludes="*.RSA, *.SF, *.DSA, META-INF/MANIFEST.MF" />
<manifest>
<attribute name = "Main-Class" value = "com.karthik.publisher"/>
</manifest>
</jar>
</target>
当我从命令提示符运行/执行 jar 时,出现以下错误
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry javax/mail/SecuritySupport.class
at sun.security.util.SignatureFileVerifier.verifySection(Unknown Source)
at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
at sun.security.util.SignatureFileVerifier.process(Unknown Source)
如您所见,我从每个 jar 中排除了 RSA、SF 和 DSA 文件以及 MANIFEST.MF,但我仍然遇到此异常。
【问题讨论】:
-
解压生成的 JAR 文件并检查它的 META-INF 目录中有哪些文件。
-
提取 JAR 文件后,我在 META-INF 目录中看到 .RSA、.SF、MANIFEST.MF、mimetype.default、mailcap.default 文件。似乎这些文件没有被排除在 build/jar 中。我怀疑构建 jar 目标有问题。