Next: , Previous: Extracting meta data, Up: Top


5 Language bindings

GNU libextractor works immediately with C and C++ code. Bindings for Java, Mono, Ruby, Perl, PHP and Python are available for download from the main GNU libextractor website. Documentation for these bindings (if available) is part of the downloads for the respective binding. In all cases, a full installation of the C library is required before the binding can be installed.

5.1 Java

Compiling the GNU libextractor Java binding follows the usual process of running configure and make. The result will be a shared C library libextractor_java.so with the native code and a JAR file (installed to $PREFIX/share/java/libextractor.java).

A minimal example for using GNU libextractor's Java binding would look like this:

import org.gnu.libextractor.*;
import java.util.ArrayList;

public static void main(String[] args) {
  Extractor ex = Extractor.getDefault();
  for (int i=0;i<args.length;i++) {
    ArrayList keywords = ex.extract(args[i]);
    System.out.println("Keywords for " + args[i] + ":");
    for (int j=0;j<keywords.size();j++)
      System.out.println(keywords.get(j));
  }
}

The GNU libextractor library and the libextractor_java.so JNI binding have to be in the library search path for this to work. Furthermore, the libextractor.jar file should be on the classpath.

Note that the API does not use Java 5 style generics in order to work with older versions of Java.

5.2 Mono

his binding is undocumented at this point.

5.3 Perl

This binding is undocumented at this point.

5.4 Python

This binding is undocumented at this point.

5.5 PHP

This binding is undocumented at this point.

5.6 Ruby

This binding is undocumented at this point.