This document describes how to run checkstyle using the command line tool. The latest version of checkstyle can be found at http://checkstyle.sourceforge.net. This command line tool is included in the checkstyle distribution.
The easiest way is to include checkstyle-all-@CHECKSTYLE_VERSION@.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 com.puppycrawl.tools.checkstyle.Main \
[-f <format>] [-p <propertiesFile>] [-o <file>] [-r <dir>] file...
Checkstyle will process the specified files and by default report errors to standard out in plain format. The options are:
Run checkstyle on a file
java com.puppycrawl.tools.checkstyle.Main Check.java
Run checkstyle on all java files in a directory
java com.puppycrawl.tools.checkstyle.Main -r src/
Run checkstyle on a file and use specified properties
java com.puppycrawl.tools.checkstyle.Main \
-p myCheckstyle.properties Check.java
Run checkstyle on a file and output to a file in XML format
java com.puppycrawl.tools.checkstyle.Main \
-f xml -o build/checkstyle_errors.xml Check.java
It is possible to run Checkstyle directly from the JAR file using the -jar option. Example would be:
java -jar checkstyle-all-@CHECKSTYLE_VERSION@.jar Check.java
Copyright © 2001 Oliver Burn. All rights Reserved.