This document describes how to run checkstyle using the command line tool. The latest version of checkstyle can be found at http://www.puppycrawl.com/checkstyle. This command line tool is included in the checkstyle distribution.
The easiest way is to include checkstyle-all-1.3.jar in the classpath. This contains all the classes required to run checkstyle. Alternatively, you must include the following in the classpath:
The command line usage is:
java -D<property>=<value> com.puppycrawl.tools.checkstyle.Main file...
checkstyle will process the specified files and report errors to standard error. The default behaviour of checkstyle can be changed by setting system properties using the -D<property>=<value> arguments to java. The following table describes what properties can be set:
| Property | Description |
| checkstyle.allow.tabs | Indicates whether to allow tabs. Defaults to "no". |
| checkstyle.allow.protected | Indicates whether to allow protected data. Defaults to "no". |
| checkstyle.allow.noauthor | Indicates whether to allow no @author tag to be defined for class and interface Javadoc comments. Defaults to "no". |
| checkstyle.maxlinelen | Specifies the maximum line length. Default value is defined here. |
| checkstyle.ignore.importlength | Specifies whether to ignore the maximum line length for import statements. Defaults to "false". |
| checkstyle.maxmethodlen | Specifies the maximum method length. Default value is defined here. |
| checkstyle.maxconstructorlen | Specifies the maximum constructor length. Default value is defined here. |
| checkstyle.maxfilelen | Specifies the maximum file length. Default value is defined here. |
| checkstyle.pattern.member | Specifies the regular expression to match against member variables. Default value is defined here. |
| checkstyle.pattern.publicmember | Specifies the regular expression to match against public member variables. Default value is defined here. |
| checkstyle.pattern.parameter | Specifies the regular expression to match against parameters. Default value is defined here. |
| checkstyle.pattern.const | Specifies the regular expression to match against static/final variables. Default value is defined here. |
| checkstyle.pattern.static | Specifies the regular expression to match against static variables. Default value is defined here. |
| checkstyle.pattern.type | Specifies the regular expression to match against type names. Default value is defined here. |
| checkstyle.header.file | Specifies the file containing the header lines. Default is to not check. |
| checkstyle.header.ignoreline | Specifies the line in the header to ignore when comparing. Default it to not ignore any line. |
| checkstyle.javadoc.relax | Specifies whether to relax checking Javadoc comments. Defaults to "no". |
| checkstyle.javadoc.ignore | Specifies whether to completely ignore checking Javadoc comments. Defaults to "no". |
| checkstyle.ignore.imports | Specifies whether to ignore checking import statements. Defaults to "no". |
| checkstyle.ignore.whitespace | Specifies whether to ignore checking whitespace. Defaults to "no". |
| checkstyle.ignore.braces | Specifies whether to ignore checking braces. Defaults to "no". |
| checkstyle.cache.file | Specifies the name of a file that can be used to cache details of files that pass checkstyle. This can signicantly increase the speed of checkstyle on successive runs. |
Run checkstyle on a file
java com.puppycrawl.tools.checkstyle.Main Check.java
Run checkstyle on a file and allow tabs
java -Dcheckstyle.allow.tabs=yes com.puppycrawl.tools.checkstyle.Main Check.java
Run checkstyle on a file and disable pattern matching
java -Dcheckstyle.pattern.parameter=. \
-Dcheckstyle.pattern.static=. \
-Dcheckstyle.pattern.const=. \
-Dcheckstyle.pattern.member=. \
com.puppycrawl.tools.checkstyle.Main Check.java
Copyright © 2001 Oliver Burn. All rights Reserved.