Setup

Bindgen is an annotation processor that you configure the Java compiler to run during its compilation phase.

Ivy/Maven Repository

You can download Bindgen releases from the Joist repo. It has both Ivy ixy.xml and Maven pom.xml artifacts, see:

http://repo.joist.ws/org/bindgen/bindgen/

You will only need bindgen.jar on your project’s classpath.

Ant/javac

If you’re using Ant/javac, you just need to:

So your code can be as little as:

    <javac destdir="bin/main">
      <classpath refid="main.classpath"/>
      <src path="src/main/java"/>
    </javac>

The javac compiler will auto-detect the Bindgen processor on your main.classpath via a Service Loader manifest file.

If you want to tweak some of the annotation processor options, you can be more explicit, e.g.:

    <javac destdir="bin/main">
      <classpath refid="main.classpath"/>
      <src path="src/main/java"/>
      <compilerarg value="-s"/>
      <compilerarg value="bin/apt"/>
      <compilerarg value="-processor"/>
      <compilerarg value="org.bindgen.processor.Processor"/>
    </javac>

Briefly:

Eclipse

The Eclipse annotation processing is more involved than javac configuration. It requires both 1.6 compiler output and also an explicit reference to bindgen.jar instead of auto-detecting it on your classath.

To setup Eclipse, use the Project Properties. Right-click on your Eclipse project and go to:

  Project Properties:
    Java Compiler:
      Ensure the "Compiler compliance level" is 1.6
      Annotation Processing:
        Check "Enable annotation processing"
        Check "Enable processing in editor"
        Optionally set "Generated source directory" to something like "bin/apt"
        Factory Path:
          Click "Add JARs" and select bindgen.jar

If you are having problems, you want to ensure that under Factory Path, clicking the “Advanced” button lists the org.bindgen.processor.Processor class. If it does not, something is not setup correctly. Try the above steps again and potentially open/close the project and/or Eclipse itself.