Castle库的JAR打包为单个JAR

Castle库的JAR打包为单个JAR

本文介绍了将带有Bouncy Castle库的JAR打包为单个JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了自己的包装器类,并且希望使用已编译的JAR文件的任何人都可以使用该包装器类.

I made my own wrapper classes and I would like that wrapper classes to be used by anyone using my compiled JAR file.

此jar文件还包含一个lib文件夹,并且还具有充气城堡库,因为包装器的目的是使调用者更轻松.因此,现在建立了名为MyLibrary.JAR的库.

This jar file also contained a lib folder and it has bouncy castle libraries as well, since the wrapper purpose is to make things easier for the caller. So now my library with name MyLibrary.JAR is built.

现在,当我将此jar作为库包含在另一个项目中时,我会看到以下错误

Now when I have included this jar as a library in another project I see the following error

线程"AWT-EventQueue-0"中的异常java.lang.NoClassDefFoundError:org/bouncycastle/operator/OperatorCreationException

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/bouncycastle/operator/OperatorCreationException

我检查了MyLibrary.Jar文件,发现里面还有另一个Lib文件夹,并且所有的弹性城堡库都在那,所以为什么我仍然看到此错误?我的图书馆jar具有这些结构文件夹

I checked MyLibrary.Jar file and found that inside there is another Lib folder and all the bouncy castle libraries are there, so why am I still seeing this error? My Library jar has these structure folders

在lib文件夹中,我有以下库

Inside the lib folder I am having following libraries

我对使用手动zip和unzip jar不感兴趣,并添加了这些库,我正在寻找我将在NetBeans上设置的内容,它将生成JAR文件以及相关的充气城堡库.

I am not interested in using manual zip and unzip jar and add these libraries I am looking for something I will set on the NetBeans and It will generate the JAR file along with the dependent bouncy castle libraies.

推荐答案

好吧,我找到了它,我需要添加如下所示的构建属性,以拥有一个自动构建单个库

Okay I found it , I need to add the build properties like below in order to have an automated build single library

 <target name="-post-jar">
    <jar jarfile="dist/PKIFrapper.jar" >
    <zipfileset src="${dist.jar}" excludes="META-INF/*" />
    <zipfileset src="src/lib/bcmail-jdk15on-155.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/bcpg-jdk15on-155.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/bcpkix-jdk15on-155.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/bcprov-ext-jdk15on-155.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/bcprov-jdk15on-155.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/bctest-jdk15on-155.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/commons-codec-1.10-javadoc.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/commons-codec-1.10-sources.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/commons-codec-1.10.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/log4j-1.2-api-2.3-javadoc.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/log4j-1.2-api-2.3-sources.jar" excludes="META-INF/*" />
    <zipfileset src="src/lib/log4j-1.2-api-2.3.jar" excludes="META-INF/*" />

    <manifest>

        <attribute name="Main-Class" value="MyLibrary.*"/>
    </manifest>
    </jar>
</target>

这篇关于将带有Bouncy Castle库的JAR打包为单个JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 21:25