If you have integrated the Maven Checkstyle Plugin , you are most likely to encounter build failures during checkstyle execution with the message:
'Wrong order for 'xxx.xxx.xxx' import'
If you are developing in IDEA, even if you optimize imports , you are most likely to get this error due to the ordering of java and javax imports. The problem is, by default IDEA order the javax imports after java imports (in version 13 and 14 at least). At first you try to fix this by manually arranging the imports, but it gets kinda annoying when this happens frequently. Luckily there is a way we can fix this by configuring IDEA to satisfy the checkstyle requirements.
Open the ‘Settings‘ (or ‘Preferences‘ in mac) window and goto
Editor > Code Style > Java. Click on ‘Imports‘ tab. In ‘Import Layout‘ area, you can arrange the import order by selecting the import type and clicking on the arrow (see image below). Once the changes are done apply the new settings. Now IDEA will make the import optimization according to the new configurations.