2013-02-16 59 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}"
另外,我认为即使在运行程序时,也需要将库添加到类路径中。

相关问题