简体   繁体   English

Eclipse中的Ant构建失败

[英]Ant Build Failed in Eclipse

I was building an jar file of my project using ANT after searching in Google found how do do it i referred this ink. 我在谷歌搜索后使用ANT构建了我的项目的jar文件,发现我怎么做这个墨水。 Below is my build.xml file 下面是我的build.xml文件

<?xml version="1.0" ?> 
<project name="ExcelData" default="compress">

    <target name="init">
        <mkdir dir="build/classes" />
        <mkdir dir="dist" />
    </target>

    <target name="compile" depends="init">
        <javac srcdir="src" destdir="build/classes" />
    </target>

    <target name="compress" depends="compile">
            <jar destfile="dist/ExcelData.jar" basedir="build/classes" />
    </target>

    <target name="execute" depends="compile">
        <java classname="com.spt.excel.data.ExcelData" classpath="build/classes" />
    </target>

    <target name="clean">
        <delete dir="build" />
        <delete dir="dist" />
    </target>

</project>

but the problem is the ANT building is failing. 但问题是ANT建筑失败了。 But i am getting errors as 但我得到的错误是

D:\Eclipse\workspace\ExcelData\src\com\spt\excel\data\ExcelData.java:24: error: package org.slf4j does not exist`

And referred this link to set tools.jar. 并将链接引用到set tools.jar。

Can Anyone tell me where i am going wrong. 谁能告诉我哪里出错了。 Thank You in advance. 先感谢您。

you have no include libraries to your ant file, I mean classpath, just add all libs that your eclipse project contains to ant file and all will work, and please read original tutorial like this one 你有没有包括库与您的Ant文件,我的意思是类路径,只需添加你的Eclipse项目包含了蚂蚁文件,一切都将工作,请阅读原始教程像所有的库这样一个

like that 像那样

<javac srcdir="${src.dir}" destdir="${classes.dir}">
    <classpath>
        <pathelement location="${lib.dir}/lib1.jar"/>
        <pathelement location="${lib.dir}/lib2.jar"/>
    </classpath>
</javac>

for libs 对于libs

<path id="mylibs">
    <fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>

<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="mylibs" debug="on"/>

add properties lib.dir 添加属性lib.dir

 <property name="lib.dir"  location="{here is path to your libraries}"/>

For Eclipse I recommend following: 对于Eclipse,我建议如下:

Right click your project -> Export -> Runnable Jar file 

Pick launch configuration, destination, extract required libraries into JAR, tick Save as ANT script

Finish.

Eventually you would have Jar file generated together with reusable Ant script. 最终,您将使用可重用的Ant脚本生成Jar文件。

Then you analyze your Ant script. 然后分析您的Ant脚本。

Difference between extracting and packaging libraries into a jar file 提取和打包库到jar文件之间的区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM