Project

General

Profile

Support #973

Add External Library to Ant Project in NetBeans

Added by Daniel Curtis 5 months ago. Updated 5 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
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.

Resources

#1

Updated by Daniel Curtis 5 months ago

  • % Done changed from 0 to 100
  • Status changed from New to Resolved

Also available in: Atom PDF