This question already has an answer here:
I just wonder if there is a command line tool for eclipse java file formatter. Or if there is an ant task to execute it.
In my scenario, there are 2 java formatters, one is for android formatter, the other is our internal formatter.
So we have to change it between these two formatter.
Not sure what exactly you are looking for but if im guessing correctly it is something like this: http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/
This describes how to execute the eclipse built in formatter using the command line. You can also enable the format per project.
来源:https://stackoverflow.com/questions/5277162/command-line-for-eclipse-java-formatter