2013-02-16 60 views
0

無法找到或加載主類的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> 

每次我跑我的罐子它給我這個錯誤,我不知道是什麼原因造成的。其他一切正常工作,我已經搜索了並發現了幾個職位,但這些問題似乎沒有爲他們工作。

回答

0

嘗試在run目標的java標記內添加classname="${main.class}"
另外,我認爲即使在運行程序時,也需要將庫添加到類路徑中。

相關問題