The formatting choices look fine, although I should probably run it to really see, but never mind.

Did you consider jacobe - it seems to have a free option, but with binaries only for win and Linux.

Gilleain

On Sunday, May 19, 2013, John May wrote:
Okay,

Done some research and unfortunately it's not as easy as you'd think. There is a couple of paid stand-alone products available but the primary open source (Jalopy) went commercial a couple of years ago. As much as I don't like eclipse the best bet seems to be to use it's formatter as a standalone. There are ant tasks which can do this and also a maven plugin. I'm not entirely sure how the ant task would work (as I don't use ant) but I guess it could pick up an environment variable. Perhaps it might be best just to do a reformat once instead of adding to the build cycle.

With the provided config file you can format from the command line as follows

eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -config ~/workspace/github/johnmay/cdk/org.eclipse.jdt.core.prefs ~/workspace/github/johnmay/cdk/src/main/
 
Most of the changes were column alignment, but unfortunately it won't do everything. For example, I could not find a way to align arrays nicely.

new IAtom[]{ new Atom("H"),
     new Atom("H"),
       new Atom("O") };

Here is what I changed from the eclipse 'java conventions [built-in]'.

Indentation
+ Tab policy: Spaces only
+ Align fields to columns
+ Indent, Spaces within 'case' body

Blank Lines
+ Before first declaration: 1

Line Wrapping
    General Settings
    + Line Wrapping: 100
    + Never join already wrapped lines

    Annotations
        Element-value pairs
        + Wrap all elements, except first element if not necessary
        + Indent on column

    'enum' declaration
        Constants
        + Wrap all elements, every element on a new line

    Function calls
        Arguments
        + Indent on column
        Explicit constructor invocations
        + Indent on column
        Object allocation arguments
        + Indent on column    
        Qualified object allocation arguments
        + Indent on column

    Expression
        Binary Expressions
        + Indent on column
        Conditionals
        + Indent on column
        Array init
        + Indent on column

    Statements
        Try-with-resources
        + Indent on column
        Multi-catch
        + Indent on column

Comments
+ Remove blank lines (javadoc)
+ Remove blank lines (block)