PMD Installation Guide for Java (2025)

Introduction

This guide provides step-by-step instructions to install PMD on Mac, Windows, and Linux for Java static analysis in 2025. PMD is a popular tool for detecting code issues and enforcing best practices.

1️⃣ Prerequisites

  • Java 8 or later
  • PMD ZIP archive (latest version from official site)
  • Internet connection for downloading packages

2️⃣ Installation on Mac/Linux

  1. Install Java:
    brew install openjdk@17 (Mac) or sudo apt-get install openjdk-17-jdk (Linux)
  2. Download the latest PMD ZIP from the official site.
  3. Extract the archive:
    unzip pmd-bin-*.zip
  4. Run PMD:
    ./pmd-bin-*/bin/run.sh pmd -d . -R rulesets/java/quickstart.xml -f text

3️⃣ Installation on Windows

  1. Install Java 8+ (e.g., from Adoptium).
  2. Download the latest PMD ZIP from the official site.
  3. Extract the ZIP file using Windows Explorer or tar -xf pmd-bin-*.zip
  4. Run PMD:
    pmd-bin-*/bin/pmd.bat -d . -R rulesets/java/quickstart.xml -f text

4️⃣ IDE Integration

  • IntelliJ IDEA: Install the PMD plugin from the JetBrains marketplace.
  • Eclipse: Install the PMD plugin from the Eclipse Marketplace.
  • Configure the plugin as per your project requirements.

FAQ

Add the PMD plugin to your Maven or Gradle build file. See the official documentation for configuration examples.

Yes, PMD supports custom rules written in Java or XPath. See the official documentation for details.

Conclusion

PMD is easy to install and use on all major platforms. Use the steps above to enforce best practices in your Java code in 2025!