我有两个班,ZipComparison
和Tczip
。Tczip
消化一个zip
文件并处理其MD5
, 同时ZipComparison
搜索.zip
条目,并比较.zip
文件的两个不同版本以确定它们是否具有相同的内容。例如,在 apackage_a
中有encodes.zip
所以我想确定在 thepackage_b
中encodes.zip
是否与.zip
在package_a
. 所以我处理MD5
,如果它们匹配,那么我不需要复制MD5
. build.xml
如下:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<path id="external.classpath">
<pathelement location="src/commons-codec-1.2.jar"/>
</path>
<target name="clean">
<delete dir="build" />
</target>
<target name="compile">
<mkdir dir="build/classes" />
<javac srcdir="src/tczip" destdir="build/classes">
<classpath>
<path refid="external.classpath" />
</classpath>
</javac>
</target>
<target name="jar">
<mkdir dir="build/jar" />
<jar destfile="build/jar/Tczip.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="tczip.ZipComparison" />
</manifest>
</jar>
</target>
<target name="run">
<java jar="build/jar/Tczip.jar" fork="true" />
</target>
</project>
所以我正在尝试创建一个ant
构建文件。ZipComparison
使用Tczip
,但是当我编译时,执行是完美的,但是,当我这样做时,ant run
我收到以下错误:
C:\Users\souzamor\workspace\tczip>ant run
Buildfile: C:\Users\souzamor\workspace\tczip\build.xml
run:
[java] Processing: bhmcommonclient.zip
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/apach
e/commons/codec/binary/Hex
[java] at tczip.Tczip.digest(Unknown Source)
[java] at tczip.Tczip.execute(Unknown Source)
[java] at tczip.ZipComparison.showFiles(Unknown Source)
[java] at tczip.ZipComparison.showFiles(Unknown Source)
[java] at tczip.ZipComparison.showFiles(Unknown Source)
[java] at tczip.ZipComparison.showFiles(Unknown Source)
[java] at tczip.ZipComparison.showFiles(Unknown Source)
[java] at tczip.ZipComparison.matchMD5(Unknown Source)
[java] at tczip.ZipComparison.main(Unknown Source)
[java] Caused by: java.lang.ClassNotFoundException: org.apache.commons.code
c.binary.Hex
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
[java] ... 9 more
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 4 seconds
我知道Tczip
在舞台上丢失了compile
,但是我怎样才能添加它,ZipComparison
这样我就没有那种错误了?谢谢