Setup Continued
Preliminaries

To start, put the checkstyle files (the jar and google_checks.xml files) into some location that you will remember. Here, we will be assuming that they are on your desktop.

Windows
  1. Create a file called 'checkstyle.bat' in the same directory as your other checkstyle files.

  2. Within this file, write the following text exactly as shown:

    
            @echo off
            java -jar C:\Users\%USERNAME%\Desktop\checkstyle\checkstyle-6.9-all.jar -c C:\Users\%USERNAME%\Desktop\checkstyle\google_checks.xml %*
            

    Then save the file.

  3. Open the environment variables dialog by opening
    Control Panel → System and Security → System → Advanced System Settings → Environment Variables

  4. Find the 'Path' variable in the lower split, and click edit.

  5. At the end of the current text, add the following (exactly as shown):

    
            ;C:\Users\%USERNAME%\Desktop\checkstyle
            

    DO NOT DELETE ANY OF THE TEXT ALREADY IN THE PATH

Now, you should be able to run checkstyle simply by calling checkstyle.bat. For example, if you want to audit the file 'CandyBar.java', you could use (in a command prompt)

    checkstyle.bat CandyBar.java
    
Mac OS X or Linux
  1. Create a file called 'checkstyle' in the same directory as your other checkstyle files.

  2. Within this file, write the following text exactly as shown:

    
            #!/bin/sh
            java -jar /path/to/checkstyle/checkstyle-6.9-all.jar -c /path/to/checkstyle/google_checks.xml "$@"
            

    Where /path/to/checkstyle/ is the full path to the checkstyle folder (you can find this out by typing pwd in a command prompt). Then save the file.

  3. Make the file executable by typing (in a command prompt):

    
              chmod +x ./checkstyle
            
  4. At a command prompt, enter the following text exactly as shown:
    
            echo 'export PATH="$PATH:/path/to/checkstyle/checkstyle"' >> ~/.bash_profile
            
Now, you should be able to run checkstyle simply by calling checkstyle. For example, if you want to audit the file 'CandyBar.java', you could use (in a command prompt)

    checkstyle CandyBar.java