Eclipse: Use Checkstyle plugin - how it works
With the Checkstyle plugin for Eclipse you can format the code in your projects uniformly and according to certain guidelines. We'll show you how to do this.
Checkstyle plugin for Eclipse: install and activate
Before you can use Checkstyle, you have to install the plugin of the same name:
- You can get the plugin directly from the manufacturer's website and install it via a link in Eclipse.
- Alternatively, you can also use the Eclipse Marketplace. If your Eclipse version has already integrated it, you will find the Market in the menu bar under "Help".
- Look for "Checkstyle" in the market and click on "Install" next to the plugin. You must then restart Eclipse for the change to take effect.
- You can make settings for the tool under "Window" -> "Preferences" -> "Checkstyle". For example, you can choose whether you'd rather follow Google's or Sun's code.
- With "Configure" you can change the specifications as you wish.
- Now you have to activate Checkstyle for individual projects that you want to check and correct. To do this, right-click on the corresponding project in the Package Explorer and select "Properties" -> "Checkstyle". Now check the "Checkstyle active for this project" (see screenshot).
- After performing step seven, the project is automatically rebuilt. Then there are appropriate warnings and notes to the left of your code in this project.
- For example, you may have exceeded the maximum line length defined in the styles of Google. Another indication could be that you have not yet integrated a standard package. Follow the instructions to disable the warnings.
Not happy with the Java IDE? We show you the 3 best alternatives to Eclipse.