How to format all Java files in an Eclipse project at one time?
Right click on the project root and select Source -> Format. This should work for at least version 3.8.1. and above.
If the above does not work, you're probably using an older Eclipse-version. In such case you can select your Source Folders by clicking on them while holding down CTRL, then select Source -> Format from the right-click -menu. Works with package-folders and class files also, in case you don't want to format the entire project.
I also had the Java Perspective ON and this was still not working. My eclipse was only formatting css and Html files, but not JAVA ones.
Then, I located this answer that explains this:
You must add Java Facet to the project to allow Java classes to be detected by Eclipse formatter
Then, you should check on PROJECT-PROPERTIES-PROJECT FACETS
and activate the Java facet for the project:
And by right-clicking on top of the PACKAGE-EXPLORER
you will find the SOURCE - FORMAT option, and it will format Java files too.
Be careful, check it´s package explorer, not Project Explorer (click Window-Show View-PackageExplorer)
This is the purpose of
Source ->Clean Up...
selecting the appropriate options.