Sunday, September 14, 2014

Command line java/c/c++ code formatting

One can use eclipse to format java code on command line. Following is the syntax:
eclipse.exe -application org.eclipse.jdt.core.JavaCodeFormatter -verbose  -config

All the files in all subfolders below specified source folder will be formatted.

for example:
eclipse.exe -application org.eclipse.jdt.core.JavaCodeFormatter -verbose  -config .settings/org.eclipse.jdt.core.prefs .\src

I don't remember where I picked it from but I guess it was from
http://blogs.operationaldynamics.com/andrew/software/java-gnome/eclipse-code-format-from-command-line

Also apparently there is a way to format C/C++ code also using eclipse, although I have not tried it.
https://github.com/x8o1Y/EclipseCCodeFormatter