Java – ant build in eclipse failed
•
Java
After Google search, I used ant to build the jar file of my project and found out how I did it. I mentioned this ink Here is my build XML file
<?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 that the ant building failed But what I got wrong was
D:\Eclipse\workspace\ExcelData\src\com\spt\excel\data\ExcelData.java:24: error: package org.slf4j does not exist`
And mention this link to set tools jar.
Who can tell me what went wrong Thank you first
Solution
Your ant file does not contain libraries. I mean classpath. Just add all the libraries contained in your eclipse project to the ant file, and everything will work normally. Please read the original tutorial, such as this one
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
<path id="mylibs"> <fileset dir="${lib.dir}" includes="**/*.jar"/> </path> <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="mylibs" debug="on"/>
Add attribute lib dir
<property name="lib.dir" location="{here is path to your libraries}"/>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码