无法找到或加载主类ant文件

时间:2013-02-16 00:04:34

标签: ant

<target name="init">
    <property name="src.dir" value="src"/>
    <property name="build.dir" value="build"/>
    <property name="apidoc.dir" value="apidoc"/>
    <property name="lib.dir" value="lib"/>

    <property name="lib.res" value="resources.jar"/>
    <property name="jar.path" value="${build.dir}/AntLabRun.jar"/>
    <property name="main.class" value="edu.gatech.oad.antlab.pkg1.AntLabMain"/>
    <path id="classpath">
        <fileset dir="${lib.dir}" includes="lib.res"/>
    </path>
</target>


<target name="jar" depends="compile">
    <manifestclasspath property="jar.classpath" jarfile="${jar.path}">
        <classpath refid="classpath"/>
    </manifestclasspath>
    <jar destfile="${jar.path}" basedir="${src.dir}">
    <manifest>
        <attribute name="Main-Class" value="${main.class}"/>
        <attribute name="Class-Path" value="${jar.classpath}" />
    </manifest>
    </jar>
</target>

<target name="clean" depends="init">
    <delete dir="${build.dir}"/>
    <delete dir="${apidoc.dir}"/>
</target>

<target name="run" depends="jar">
    <java jar="${jar.path}" fork="true"/>
</target>

<target name="all">
    <antcall target="init"/> 
    <antcall target="prepare"/>
    <antcall target="compile"/>
    <antcall target="javadoc"/>
    <antcall target="jar"/>
    <antcall target="run"/>
</target>

每次我运行我的jar都会给我这个错误,我不知道是什么导致了它。其他一切工作正常,我已经google了一下,发现了几个同样问题的帖子,但没有任何对他们有用的东西似乎对我有用。

1 个答案:

答案 0 :(得分:0)

尝试在classname="${main.class}"目标的java标记内添加run
另外,我认为即使在运行程序时,也需要将库添加到类路径中。

相关问题