2015-04-07 32 views
2

我想執行如下所示添加自定義規則 - 類未找到問題

http://pmd.sourceforge.net/pmd-5.3.0/customizing/howtowritearule.html

WhileLoopsMustUseBracesRule顯示找不到類[標準問題的一個初學者,我相信]

這個例子

方法嘗試:

1) cd pmd-5.3.0 
2) created WhileLoopsMustUseBracesRule.java and ruleset.xml as per shown in the page. 
3) javac -cp [all the required jar files seperated by ; since it is windows pc ] WhileLoopsMustUseBracesRule.java 
4) bin/pmd.bat -d [code on which pmd has to check the rule] -f xml -R ruleset.xml 

上述步驟都讓我沒有階級發現錯誤,在這裏開發人員評論稱se臺階工作 [http://sourceforge.net/p/pmd/discussion/188192/thread/7a34d224/]

請讓我知道,如果我失去了什麼。

我嘗試添加類文件以及 其他方法試圖直接到類路徑:

1) compiled the WhileLoopsMustUseBracesRule.java file and got the .class file. 
2) created a jar using jar -cf jar_name jar_file command 
3) added that jar file in the class path , using set CLASSPATH and also tried adding directly in the batch file used to run PMD i.e. pmd.bat 

請幫助!

回答

2

我找到了解決方案!

假如分別使用

set CLASSPATH=path\to\my\classfile 

,然後在批次我不得不添加%CLASSPATH%,否則使用-cp被複位類路徑我想設置CLASSPATH。這對我有效。

謝謝