Using AGLIB (AGAPI) with Java AG wrapper

Unix-like systems

The Java AG wrapper module is installed in <prefix>/lib/ag_wrapper/java, where <prefix> is a path where the package is installed, and it can be specified using the --prefix option at configuration time. The default value of <prefix> is /usr/local.

Here is example Java code that uses the Java AG wrapper:

public class MyClass {
  static {

  public static void main(String[] args) {
    String agsetId = jag.CreateAGSet("TIMIT");
    String timelineId = jag.CreateTimeline(agsetId);
    String ag = jag.CreateAG(agsetId, timelineId);
    String a1 = jag.CreateAnchor(ag);
    jag.SetAnchorOffset(a1, 1.0);
    String a2 = jag.CreateAnchor(ag);
    jag.SetAnchorOffset(a2, 2.0);
    String ann = jag.CreateAnnotation(ag, a1, a2, "word");
    jag.SetFeature(ann, "label", "cat");

Lines 2-4 load the Java AG wrapper. For this code to work, the LD_LIBRARY_PATH and CLASSPATH environment variables should be set properly to contain the installation path of the module; e.g.:


Lines 7-14 show how AGAPI functions are called. Note that each function is prefixed by `jag.'.

NOTE: Please don't forget to set LD_LIBRARY_PATH properly for the other required shared libraries (libag and plugins). See Post-installation for details.

Annotation Graph Toolkit