Table of Contents

Adding libraries to Ant project


Ant project is opened in Visual Studio. You can find instructions how to create an Ant project in this section. Also, at least one compilation target (with Javac task) is configured. This section shows how to configure tasks within a target.


Adding libraries into a Java project means actually adding them to the classpath parameter of the compiler. You can do it manually, by editing the properties of the Javac task and modifying 'classpath' property:

The parameter accepts multiple paths separated by semicolons. You can also use Ant variables in usual way ('${name}' syntax). More advanced Ant techniques (like using a nested classpath element) are also supported. For the sake of simplicity these methods are not described here.

Besides manually specifying the classpath, IntegraStudio offers several more elaborate and convenient mechanisms to handle external libraries. Those are described below.

Configuring the library directory

First, you can set the project library directory. This is a subdirectory inside the project directory, where external JARs are residing. The subdirectory is usually named 'lib'. Configuring it is optional. It enables the library copying feature when using Add Java libraries... function (described below).

To set the library directory, open Properties on the project node in Solution Explorer. Go to General tab and enter the name into Library directory field:

Using the 'Add Java libraries' option

Right-click the project node in Solution Explorer, open the Ant menu and choose the Add Java libraries option. The library selector window will appear:

The window on the left hand side lists compilation tasks found in the project, which are suitable for adding libraries to their classpaths. Currently these are Javac tasks. Each task name contains its target name and the description (usually taken from key properties, like srcdir), so that you can identify it when there are multiple possible tasks. You can select / unselect a task by clicking the checkbox next to it.

The window on the right hand side lists JAR and directory paths to be added to selected tasks. You can add items to this list by clicking Add archive (for JARs and other Java archives) or Add directory (for class file directories). You can remove elements by clicking Remove, as well as change the order using Up and Down buttons.

Added paths are relative to the Ant project file whenever possible -- unless you enable the Always use absolute paths option (which forces absolute paths).

Another option is to use Maven central repository (available to all Internet users) to select and install specific library. Although the project is being built by Ant, there is no restriction against using Maven just to choose and download the JAR to local directory (caution: you need working Internet connection). To do this, click From repository... button. The first time you do this, if you have not use Maven yet, an index build notification may appear:

In such case, click Yes, wait until the index downloads and finishes processing (may take several minutes), then open Add Java libraries and click From repository... again. Index generation should happen only once. After that, clicking From repository... will show the Maven repository browser:

Choose desired library and version. For some libraries, there will be another level in the tree with default option. If you see it, click on it. When library attributes appear in the window on the right, click OK.

Now IntegraStudio will instruct Maven to download chosen library along with all dependencies. Therefore you can end up with more than one JAR. Libraries will be copied to the lib subdirectory and added to the window. Click OK to finish.

Caution: libraries chosen in the Maven browser must actually have JAR form (this is called jar packaging type in Maven terminology). Otherwise you will encounter error message. Not all libraries in Maven repository have JARs.

Table of Contents

Copyright (C) 2014-2016 SOFT-ERG. All rights reserved.