我正在尝试执行此处显示的示例
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
上面的步骤给了我没有找到类错误,这里开发人员评论说这些步骤有效 [http://sourceforge.net/p/pmd/discussion/188192/thread/7a34d224/]
如果我错过了什么,请告诉我。
我也尝试将类文件直接添加到classpath中 尝试了其他方法:
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
请帮忙!
答案 0 :(得分:2)
我找到了解决方案!
必须使用
单独设置CLASSPATHset CLASSPATH=path\to\my\classfile
然后在批处理中我必须添加%CLASSPATH%,否则使用-cp重置类路径我猜。这对我有用。
由于