title: How add custom rule in pmd and use it from terminal
body: <p>I have written a custom rule in pmd and written the rule class.</p>
  
  <p>The custom rule is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;ruleset name="My custom rules"
   xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0              http://pmd.sourceforge.net/ruleset_2_0_0.xsd"&gt;
      &lt;rule name="WhileLoopsMustUseBracesRule"
       message="Avoid using 'while' statements without curly braces"
       class="WhileLoopsMustUseBracesRule"&gt;
          &lt;description&gt;
              Avoid using 'while' statements without using curly braces
          &lt;/description&gt;
          &lt;priority&gt;3&lt;/priority&gt;
          &lt;example&gt;
              &lt;![CDATA[
                  public void doSomething() {
                      while (true)
                      x++;
                  }
              ]]&gt;
          &lt;/example&gt;
      &lt;/rule&gt;
  &lt;/ruleset&gt;
  </code></pre>
  
  <p>and the class is:</p>
  
  <pre><code>import net.sourceforge.pmd.lang.java.rule.*;
  import net.sourceforge.pmd.lang.java.ast.*;
  public class WhileLoopsMustUseBracesRule extends AbstractJavaRule {
      public Object visit(ASTWhileStatement node, Object data) {
          System.out.println("hello world");
          return data;
      }
  }
  </code></pre>
  
  <p>Now when I type the command from the terminal </p>
  
  <pre><code>sh run.sh pmd -d /Users/sree/Documents/learning/programs/java xml /Users/sree/Desktop/customrule.xml 
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Was passed main parameter 'xml' but no main parameter was defined</p>
  </blockquote>
  
  <p>Now to include custom rule so that I can access it from the terminal and after bundling up both the rule and the ruleset.xml file in a jar file how to include it in the class path </p>
  
  <p>NOTE: I am using a mac and not a Windows operating system</p>