Support #973
Add External Library to Ant Project in NetBeans
Start date:
05/12/2022
Due date:
% Done:
100%
Estimated time:
Description
This is a simple guide on how to install an external .jar library using an Ant project in NetBeans.
- In the project root directory create a
lib
and add the library.jar
files. - From NetBeans, in the Project panel open the
build.xml
file. - Edit the file and add the following inside the
<project>
tag:<property name="lib.dir" value="lib"/> <path id="classpath"> <fileset dir="${lib.dir}" includes="**/*.jar"/> </path> <target name="compile"> <mkdir dir="${classes.dir}"/> <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/> </target> <target name="run" depends="jar"> <java fork="true" classname="${main-class}"> <classpath> <path refid="classpath"/> <path location="${jar.dir}/${ant.project.name}.jar"/> </classpath> </java> </target>
Now all .jar
files added into the lib/
folder will be automatically included in the NetBeans project.