I can't reproduce your problem and I can't exactly make sense of the error message.
According to the error message, you have extracted PMD 5.4.6 into C:\pmd
, so that the directory C:\pmd\pmd-bin-5.4.6
exists. Inside this directory, there are two subdirectories: bin
- which contains pmd.bat
and lib
, which contains the necessary jars to be put onto the classpath.
So, without further configuration of your system, you should be able to run simply C:\pmd\pmd-5.4.6\bin\pmd.bat
in a command shell - you should see the help screen (and not the NoClassDefFound exception).
Can you try this? Does that work for you?
If not -> reinstall PMD as your installation seems to be broken somehow.
I see, that you are calling pmd with just using pmd
- this works, if you are currently in the directory C:\pmd\pmd-bin-5.4.6\bin
- or if you add this directory to your PATH
environment variable. Even if I do this, it works for me, regardless in which directory I'm in.
Did you configure something like the PATH
environment variable?
I cannot make sense out of the error message - it claims, it can't find a class named "C:\pmd\pmd-bin-5/4/6\bin//\lib\asm-5/0/4/jar". This is not a class name, it looks like a manipulated class path - and also look at the mix of forward and backward slashes. The next part of the error is "C:\pmd\pmd-bin-5.4.6\bin..\lib\asm-5.0.4.jar" - while it might seem to be right, that there is a slash missing - it still doesn't make sense. The error message said, that it could not find the main class - but the main class is called net.soureforge.pmd.PMD
.
For reference, here is the original content of pmd.bat
:
@echo off
set TOPDIR=%~dp0..
set OPTS=
set MAIN_CLASS=net.sourceforge.pmd.PMD
java -classpath %TOPDIR%\lib\* %OPTS% %MAIN_CLASS% %*
Can you compare this with your pmd.bat
?
I suspect, your file looks somehow different.
You can also run PMD without the batch file, e.g.:
java -classpath C:\pmd\pmd-bin-5.4.6\lib\* net.sourceforge.pmd.PMD -d path-to-source\com\vaannila\domain\User.java -f text -R java-basic
Does that work for you?
P.S.: It's true, that PMD 5.4.6 is the last one, that runs on Java 1.6. But that doesn't mean, that newer versions of PMD cannot analyze Java 1.6. code. You would just need a recent java runtime (e.g. java 10 or 11) for executing PMD and a separate JDK for building your project. PMD can analyze any version of java, it doesn't depend on the java version, it is running with.
C:\pmd\pmd-bin-5.4.6\bin..\lib\asm-5.0.4.jar
should have a slash betweenbin
and..
– Mad PhysicistC:\pmd\pmd-bin-5.4.6\lib\asm-5.0.4.jar
exists, you should consider submitting a bug report. – Mad Physicist