I have used PMD before on Windows. I found this video very helpful for advising me of the correct PMD command to input for Windows.

I want to use PMD on Mac. I have installed PMD (I know it's installed because by inputting 'pmd pmd -help', I get info) but I am not able to give the correct PMD terminal command.

I used the format below on Windows and it worked correctly:

pmd –d “[Your path to the folder, for example pmdCodeAnalysis]” – f html –R “[Your path to pmdCodeAnalysis\Rules\ApexRules.xml” –reportfile “..\PMDOutput.html”

but inputting what I perceive to be the Mac equivalent doesn't work.

pmd pmd -ls /Users/andyhitchings/Desktop/pmd/Code -f html -R /Users/andyhitchings/Desktop/pmd/Rules/ApexRules.xml -reportfile “../pmdOutput.html”

Can anyone advise what the correct command should be to get PMD to work on Mac?

Thank you,

  • Did you try this ? pmd -d "Project Dir Path till src" -R apex-ruleset -language apex -f html > "Report Folder Path\PMDReport.html" May 10, 2018 at 8:49
  • you must have downloaded PMD, open bin folder inside that and from that same path open Command Prompt and execute above command. May 10, 2018 at 9:01
  • I'm not at my Mac to look, but as a side note, there are plugins for both Eclipse and Visual Studio Code to run PMD in the IDE.
    – David Reed
    May 10, 2018 at 9:23
  • 1
    \Users\andyhitchings\Desktop\pmd\6.2.0\bin\Code\1.apxc.java , is this a correct path where you have added your source code to scan ? May 10, 2018 at 9:58
  • 1
    The command line arguments don't change. -d is always -d; it would never change to -ls.
    – Adrian Larson
    May 10, 2018 at 16:53

3 Answers 3


Many fragments of you command look wrong when I compare to what I normally use and what is described here in the docs:https://pmd.github.io/pmd-6.3.0/pmd_userdocs_getting_started.html

E.g. there is no -ls parameter. You have to use -d as in Windows. I highly recommend to start with a simple command where no reports are written to boil down the problem to a specific fragment.

$ ./bin/run.sh pmd -d ../../../src/classes/ -f html -R rulesets/apex/basic.xml -language apex
  • 1
    Thank you so much, Robert! I have now got this brilliant tool working on mac. The command I used in the end was: pmd pmd -d ../../codeX -R /Users/andyhitchings/Desktop/pmd/Rules/ApexRules.xml -language apex -f html > /Users/andyhitchings/Desktop/pmdReport.html from the bin folder of the PMD directory. May 11, 2018 at 7:13

Here is the command, you need to input this from bin folder of your PMD

pmd -d "Project Dir Path till src" -R apex-ruleset -language apex -f html > "Report Folder Path\PMDReport.html"

How I execute this command to scan my source code from local drive

pmd -d "C:\Demo Folder\src" -R apex-ruleset -language apex -f html > "C:\Users\Nachiket\Desktop\Reports\PMDReportName.html"


Project Dir Path till src -- > "C:\Demo Folder\src" I have my source code stored here, C drive, folder name "Demo Folder"

"Report Folder Path\PMDReport.html" -- > "C:\Users\Nachiket\Desktop\Reports\PMDReportName.html", I want to store my report here after PMD command finishes its execution.

In Your case,

pmd -d "Project Dir Path till src" -R apex-ruleset -language apex -f html > "Report Folder Path\PMDReport.html"

you can execute this command like following to scan your source code from local drive

pmd -d "\Users\andyhitchings\Desktop\pmd\6.2.0\bin\Code\1.apxc" -R apex-ruleset -language apex -f html > "\Users\andyhitchings\Desktop\pmd\6.2.0\bin\reportInfo\PMDReportName.html"


Project Dir Path till src -- > "\Users\andyhitchings\Desktop\pmd\6.2.0\bin\Code\1.apxc" You have your source code stored here.

"Report Folder Path\PMDReport.html" -- > "\Users\andyhitchings\Desktop\pmd\6.2.0\bin\reportInfo\PMDReportName.html", You want to store your report here after PMD command finishes its execution.

  • Thanks for your help. Unfortunately, i'm still returning an error. A file is created but it reads: '-d is NOT a valid application name, valid options are:pmd, cpd, cpdgui, designer, bgastviewer, designerold'. May 10, 2018 at 10:33
  • \Users\andyhitchings\Desktop\pmd\6.2.0\bin\Code\1.apxc , is this a correct path, do you have your source code stored in PMD bin folder and what type of file 1.apxc is ? can you try by 1.cls May 10, 2018 at 10:37
  • @AndyHitchings or try removing your file out of PMD folder,apex class are stored with extension as .cls May 10, 2018 at 10:42
  • thanks for your help but it still doesn't work. The command just hangs and I don't get the expected output. PMD works flawlessly on Windows but it doesn't work well on Mac, at least for me. Also, on Mac, I can't get PMD to work with Eclipse. Frustrating to say the least. Thanks for your efforts and help anyway! May 10, 2018 at 11:03

You can also use the SFDX-CLI code scanner instead of running PMD on your own. You should be able to install this into your CI runner and do a force installation.

SFDX-CLI Scanner

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.