Checkstyle comes by default with configurations files supporting Sun Code Conventions and Google Java Style but nearly everything can be configured. New checks can be written in java classes so nearly all kind of coding standards can virtually be implemented with Checkstyle.
On Ubuntu you can install CheckStyle has following:
sudo apt-get install checkstyle
Installing CheckStyle as a standalone tool is easy:
- Create a directory
- Copy the jar file into
%SCRIBESTOOLS%\CheckStyle\checkstyle-all.jar(remove the version number).
- Copy the files
checkstyle.shinto the directory.
- Add the
%SCRIBESTOOLS%\CheckStyledirectory to the path.
You check the installation as following. The option
the CheckStyle help and version respectively:
checkstyle -h checkstyle -v
If you have a java program at hand (let’s say
MyProg.java) and you want to
use Sun Code Conventions on it type:
checkstyle -c /sun_checks.xml MyProg.java