Automate Java coding standards with Checkstyle

Checkstyle analyzes Java source code against configurable rules for naming, imports, formatting, Javadoc, class design, and more. It helps teams enforce consistent coding standards automatically.

Get Started Browse Checks

See Checkstyle in Action

Configure a rule, run Checkstyle against your Java source, and get a precise violation.

1 - Configure

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
  <module name="TreeWalker">
    <module name="AvoidStarImport"/>
  </module>
</module>

2 - Your Java code

import java.util..*;
class Test {
  List names;
}

3 - Run Checkstyle

$ java -jar checkstyle-13.11.0-all.jar
    -c config.xml Test.java
[ERROR] Test.java:1:1: Using the '.*' form
    of import should be avoided - java.util.*.
    [AvoidStarImport]

Learn more about configuration and running Checkstyle.

What can Checkstyle check?

View all checks →

Try a few more checks:

class myClass {}

ERROR Test.java:1:7: Type name 'myClass' must match pattern '^[A-Z][a-zA-Z0-9]*$'. [TypeName]

Enforces PascalCase naming for classes, interfaces, enums, and annotations for consistency.

class MyClass {
  public void method() {}
}

ERROR MyClass.java:1:1: Class 'MyClass' should be declared as final. [FinalClass]

Ensures classes that are not designed for extension are marked as final to prevent inheritance issues.

if (retries > 3) {
  throw new RuntimeException();
}

ERROR Retry.java:1:15: '3' is a magic number. [MagicNumber]

Flags unexplained numeric literals buried in logic that should be named constants.

// Missing javadoc
public void method() {}

ERROR MyClass.java:2:1: Missing a Javadoc comment. [JavadocStyle]

Ensures public methods have Javadoc comments for proper documentation.

public void method()
{
  // code
}

ERROR MyClass.java:2:1: '{' should be on the previous line. [LeftCurly]

Enforces opening braces to be on the same line as the declaration for consistent formatting.

Where Checkstyle fits

Checkstyle focuses on configurable, source-level checks and processes Java files one at a time — naming, imports, Javadoc, formatting, and class design. It doesn't determine expression types or build a full inheritance hierarchy, so it's commonly used alongside tools that perform whole-program analysis. Read the detailed limitations for specifics.

Make Checkstyle yours

Adopt an established configuration as a practical starting point, or define exactly which rules apply to your codebase.

Use it in your workflow

One configuration, everywhere it needs to run — your build, your terminal, and your CI pipeline.

Checkstyle also plugs into your CI/CD pipeline. See the Active Tools.

Ready to try Checkstyle?

Choose an integration above, adopt a supplied configuration or write your own, and run Checkstyle against your Java sources. Current release is 13.11.0.

Get Started Configuration Browse Checks


Additional Information

Previous Version Documentation

The current website contains the documentation for the latest release only. We only support this latest version.
You can find documentation for most old versions using a URL format like https://checkstyle.sourceforge.io/version/X.X where "X.X" is the version number.
Example: https://checkstyle.sourceforge.io/version/6.18 for version 6.18.

Development Cycle

Release:
  • happens at the end of each month if functional changes exist in the master branch of our repo
  • can happen by request by any user who is impacted, but it is not always guaranteed.

Checkstyle is following its own view of Hybrid Romantic and Semantic Versioning: This is in the form of "First.Second.Third"

First digit is representing Romantic version. When it is the only number increasing, the maintainers marked it as a noticeably large breaking compatibility or major conceptual change which occurred from their perspective.
Second digit is Semantic version which is a combination of major and minor. When it is the only number increasing, it means that either some breaking compatibility happened or new features/modules were introduced.
Third digit is Semantic version which is the patch version. When it is the only number increasing, it means that only defects are fixed.

Checkstyle is not using Semantic Versioning due to the reason explained at issue #3709.

JRE and JDK

Runtime of Checkstyle is limited only by minimal version or JRE.

Checkstyle version JRE version
13.x 21 and above
11.x, 12.x 17 and above
10.x 11 and above
7.x, 8.x, 9.x 8 and above
6.x 6 and above
5.x 5 and above

Checkstyle currently is confirmed to be buildable by all JDKs from 21 through 25. Most recent JDKs may be supported. Please report an issue if there are any problems with recent JDKs.

Supported Java Language Version

Checkstyle can parse all Java language features introduced in Java 22 and below. We may support preview features depending on community demand.

Please report an issue if you encounter any issues with the support of the latest Java language features.

Limitations

Checkstyle is a single file static analysis tool, for more details please read the full list of limitations.

Additional Checks

There are other projects that provide additional checks:

Project name Link Remarks
Checkstyle addons checkstyle-addons Provides additional custom rules and enhancements for Checkstyle.
SevNTU checkstyle sevntu-checkstyle Offers a collection of advanced static analysis checks for Java code.
check-tfij-style check-tfij-style Provides opinionated Checkstyle rules based on best practices.

If you have written a plugin for other IDEs, please let us know, so we can provide a link here.