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.
Create a file called 'checkstyle.bat' in the same directory as your other checkstyle files.
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.
Open the environment variables dialog by opening
Control Panel → System and Security → System → Advanced System Settings → Environment Variables
Find the 'Path' variable in the lower split, and click edit.
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
checkstyle.bat CandyBar.java
Create a file called 'checkstyle' in the same directory as your other checkstyle files.
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.
Make the file executable by typing (in a command prompt):
chmod +x ./checkstyle
echo 'export PATH="$PATH:/path/to/checkstyle/checkstyle"' >> ~/.bash_profile
checkstyle CandyBar.java