Fork me on GitHub

Apache OpenNLP Code Conventions

The Apache OpenNLP code should follow our code conventions. All code which is contributed to the project should adhere to these guidelines.

  • Use 2 spaces for indentation. No tabs!

  • Place open braces on the same line as the declaration, for example:

    public class Foo extends Bar {
      public static void main(String args[]) {
        try {
          for (int i = 0; i < args.length; i++) {
        catch(NumberFormatException e) {
  • Wrap lines longer than 80 to 100 characters. For wrapped lines use an indent of 4 characters.

  • Within a class or interface, definitions should be ordered as follows:

  • Inner classes

  • Class (static) variables

  • Instance variables

  • Constructors

  • Methods

  • Do not use package imports, for example:

    import org.apache.opennlp.*

  • For other cases, we try to follow Java code conventions as much as possible.

Formatter and Style files

  • A code formatter file for Eclipse can be found here and the import order file here.

  • A code formatter file for IntelliJ can be found here.