2015-04-07 49 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。这对我有效。

谢谢