我为我的项目创建了一个ant build 我在提取像myfile.class(r)这样的jar文件时看到了一些不同的类名 并且此类文件的大小与已编译的类文件的大小不同 为什么会这样呢? 当我运行jar时,我得到了无法找到方法的异常。 但我出口的罐子形成了日食工作。
这是我的build.xml文件
<path id="master-classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<manifestclasspath property="lib.list" jarfile=".">
<classpath refid="master-classpath" />
</manifestclasspath>
<target name="clean" description="Clean output directories">
<delete dir="${build.dir}"/>
</target>
<target name="build" description="Compile source tree java files">
<echo>copy src files</echo>
<mkdir dir="${copy.dir}"/>
<copy todir="${copy.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.class"/>
<include name="**/*.java"/>
<include name="**/*.properties"/>
<include name="**/*.MIB"/>
<include name="**/*.java.bak"/>
</fileset>
</copy>
<echo>Compiling the source code</echo>
<echo>Apache Ant java version is ${ant.java.version}</echo>
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" srcdir="${copy.dir}" source="1.6" target="1.6" debug="on">
<classpath refid="master-classpath"/>
</javac>
<copy todir="${build.dir}">
<fileset dir="${src.dir}/src">
<exclude name="**/*.java"/>
<exclude name="**/*.class"/>
<include name="**/*.properties"/>
<include name="**/*.MIB"/>
</fileset>
</copy>
</target>
<target name="jar" depends="build">
<mkdir dir="${jar.dir}"/>
<echo>building jar!</echo>
<jar destfile="${jar.dir}/${ant.project.name}.jar" >
<fileset dir="${build.dir}" >
<include name="**/*.class" />
<include name="**/*.properties" />
<include name="**/*.MIB" />
<include name="**/*.java.bak"/>
<include name="**/*.png"/>
<include name="**/*.jpg"/>
</fileset>
<zipfileset includes="**/**.**" src="${lib.dir}/junit.jar"/>
<zipfileset includes="**/*.*" src="${lib.dir}/mysql-connector-java-5.0.8-bin.jar"/>
<zipfileset includes="**/*.*" src="${lib.dir}/NicManager.jar"/>
<zipfileset includes="**/**.**" src="${lib.dir}/log4j-1.2.14.jar"/>
<zipfileset includes="**/*.*" src="${lib.dir}/snmp4j-1.11.3.jar"/>
<zipfileset includes="**/*.*" src="${lib.dir}/snmp4j-agent-1.4.3.jar"/>
<zipfileset includes="**/*.*" src="${lib.dir}/NMSLookAndFeel.jar"/>
<zipfileset includes="**/*.*" src="${lib.dir}/rt.jar"/>
<manifest>
<attribute name="Main-Class" value="com.ushustech.nmsazzist.NMSAzzistApp" />
<attribute name="Class-Path" value="${lib.list}"/>
</manifest>
</jar>
</target>
<target name="main" depends="clean,jar"/>
答案 0 :(得分:1)