> For the complete documentation index, see [llms.txt](https://docs.flxbl.io/flxbl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flxbl.io/flxbl/sfp/analysing-a-project/code-analyzer-prerequisites.md).

# Code Analyzer prerequisites

The `pmd` and `cpd` engines run on the JVM. The `eslint` engine does not and needs neither of these.

| Requirement                    | Version                      |
| ------------------------------ | ---------------------------- |
| Java                           | `11.0.0` or later, on `PATH` |
| Code Analyzer engine libraries | `0.40.0` for sfp v51         |

To pin a specific JDK instead of the one on `PATH`, set `java_command` in the Code Analyzer configuration file:

```yaml
# config/code-analyzer.yml
engines:
  pmd:
    java_command: /usr/lib/jvm/java-21-openjdk/bin/java
```

### Step 1: Download the engine libraries

```bash
curl -sL https://registry.npmjs.org/@salesforce/code-analyzer-pmd-engine/-/code-analyzer-pmd-engine-0.40.0.tgz \
  | tar -xz -C /tmp
```

The tarball has SHA-1 `3fba2fb397f31861691862fa8a692f99c145b684`. Where npm is available, `npm install @salesforce/code-analyzer-pmd-engine@0.40.0` fetches the same package into `node_modules/@salesforce/code-analyzer-pmd-engine/`.

### Step 2: Copy them into place

| Platform    | Copy `dist/java-lib` to                            | Create `package.json` in              |
| ----------- | -------------------------------------------------- | ------------------------------------- |
| **Linux**   | `/opt/flxbl-io/dist/java-lib`                      | `/opt/flxbl-io/`                      |
| **macOS**   | `/Applications/sfp-pro.app/Contents/dist/java-lib` | `/Applications/sfp-pro.app/Contents/` |
| **Windows** | `C:\Program Files\flxbl-io\dist\java-lib`          | `C:\Program Files\flxbl-io\`          |

The `package.json` holds `{"name":"sfp","version":"0.0.0"}`.

#### Linux

```bash
sudo mkdir -p /opt/flxbl-io/dist/java-lib
sudo cp -r /tmp/package/dist/java-lib/* /opt/flxbl-io/dist/java-lib/
sudo sh -c 'printf "{\"name\":\"sfp\",\"version\":\"0.0.0\"}" > /opt/flxbl-io/package.json'
```

#### macOS

```bash
APP=/Applications/sfp-pro.app/Contents
sudo mkdir -p "$APP/dist/java-lib"
sudo cp -r /tmp/package/dist/java-lib/* "$APP/dist/java-lib/"
sudo sh -c "printf '{\"name\":\"sfp\",\"version\":\"0.0.0\"}' > $APP/package.json"
```

Adding files to a signed application bundle invalidates its code signature. If macOS then declines to launch the binary, reinstall the application and run sfp from a Node.js package tree instead.

#### Windows

Run in PowerShell as Administrator:

```powershell
$url = 'https://registry.npmjs.org/@salesforce/code-analyzer-pmd-engine/-/code-analyzer-pmd-engine-0.40.0.tgz'
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\pmd-engine.tgz"
tar -xzf "$env:TEMP\pmd-engine.tgz" -C $env:TEMP

$target = 'C:\Program Files\flxbl-io'
New-Item -ItemType Directory -Force -Path "$target\dist\java-lib" | Out-Null
Copy-Item "$env:TEMP\package\dist\java-lib\*" "$target\dist\java-lib\" -Recurse -Force
'{"name":"sfp","version":"0.0.0"}' | Set-Content "$target\package.json" -NoNewline
```

### Step 3: Verify

```bash
sfp analyze --code-analyzer-engines pmd,cpd
```

```
Selected 99 rules for analysis
Running code analysis...
```

The count varies with the project. `Rules Checked` in the results summary reports the same number, and is greater than zero.

### If the libraries are missing

```
| Error: Could not find or load main class com.salesforce.sfca.pmdwrapper.PmdWrapper
Selected 0 rules for analysis
Rules Checked: 0
```

The command exits `0` in this state, including with `--fail-on code-analyzer`. Where the analyzer gates a pipeline, assert on `Rules Checked` rather than the exit status alone. `ENOENT: no such file or directory, open '/opt/flxbl-io/package.json'` means the JAR files are in place but the `package.json` from Step 2 is not.

### Upgrading sfp

Upgrading sfp does not update these libraries. Repeat Step 1 and Step 2 when the required engine version changes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flxbl.io/flxbl/sfp/analysing-a-project/code-analyzer-prerequisites.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
