# Troubleshooting

Start with `jpm --version`, `node --version`, and `jpm doctor --json` from the project root. The doctor output helps locate configuration problems; it does not prove network access or a successful Maven build.

| Symptom | What to check |
| --- | --- |
| `jpm: command not found` | Run `npm install -g java-npm-cli`. On macOS or Linux, check that the `bin` directory under `npm prefix -g` is on your shell's PATH. On Windows, check that the directory printed by `npm.cmd prefix -g` is on PATH. If PowerShell blocks scripts, install with `npm.cmd install -g java-npm-cli` and run `jpm.cmd`. |
| npm cannot find `java-npm-cli` | Check the spelling: the package is `java-npm-cli`, not `jpm` or `java-npm`. Run `npm view java-npm-cli version --registry=https://registry.npmjs.org/` (`npm.cmd view …` if PowerShell blocks scripts). If that succeeds, check your configured registry or mirror. [Published package](https://www.npmjs.com/package/java-npm-cli) |
| Node 22 required | Select Node 22+ with your version manager. Check `node --version` in the same shell running jpm. |
| No project manifest | Run project commands from the generated application's root, not the jpm source repository or a source subdirectory. |
| JDK not found | Run `jpm jdk list`; select a complete JDK with both java and javac, or explicitly run `jpm jdk install <major>`. |
| JDK older than target | Select a JDK at least as new as `package.json.java.version`; do not silently lower the compilation target. |
| Shell Java differs from jpm | Inspect `jpm jdk env`; evaluate it in bash/zsh if you also want to switch that terminal. |
| Missing/non-executable Maven Wrapper | Restore the generated wrapper files. On macOS/Linux, restore executable permission with `chmod +x mvnw`. |
| Modified/unmanaged POM | Back it up and review the changes. jpm will not overwrite it. Remove it only if you intend to regenerate from JSON with `jpm sync`. |
| Maven fails after `jpm add` | The dependency declaration remains saved. Correct the coordinate/version or network issue and run `jpm install`, or remove it explicitly. |
| Initializr rejects a version | Choose a version currently offered by Initializr. Avoid assuming an old Boot/Java combination is still offered. |
| Port 8080 already used | Run `jpm dev -- -Dspring-boot.run.arguments=--server.port=8081`. |
| Java compilation fails during dev | Read the Maven output, fix the source, and save again. A failed compilation should not trigger a successful reload. |
| Config/dependency change is not reflected | Stop and restart `jpm dev` after dependency, JDK, or build-configuration changes. |
| Request succeeds but the sample test fails | The generated HTTP test asserts the initial greeting. After changing the controller, restore the greeting or update the test's expectation before running tests. |
| Interrupted JDK installation | Verify no installer is active before removing the reported stale lock. Move an incomplete installation aside; jpm will not overwrite it. |

## Network and private repositories

Use the last command and download shown in the terminal to identify the service that needs network access.

1. **Create the project.** `jpm create` fetches the template from Spring Initializr. Check network or proxy access to that service, or select a compatible HTTPS mirror with `--initializr` or `JPM_INITIALIZR_URL`.
2. **Select Java.** Run `jpm jdk list 21`. If JDK 21 is already installed, point `JAVA_HOME` at its installation directory and retry `jpm jdk use 21`. An IDE project SDK works if both its `bin/java` and `bin/javac` report version 21. jpm downloads Temurin when local discovery finds no match. See [configuration](https://coderserio.github.io/java-npm/docs/configuration/) for separate metadata and archive mirrors.
3. **Start Maven Wrapper.** On the first `jpm install`, the wrapper may need to download Maven itself. If that download stalls, check the `distributionUrl` in `.mvn/wrapper/maven-wrapper.properties`.
4. **Resolve project dependencies and plugins.** If Maven starts but downloads from Central stall, create a user-level `.m2/settings.xml` as shown below, then retry `jpm install`. If the file already exists, merge the `<mirror>` entry into its `<mirrors>` section. The following example uses Aliyun. Use your team's mirror when applicable.

```xml
<settings>
  <mirrors>
    <mirror>
      <id>aliyun-central</id>
      <mirrorOf>central</mirrorOf>
      <url>https://maven.aliyun.com/repository/central</url>
    </mirror>
  </mirrors>
</settings>
```

## Before filing an issue

Use the bug-report template with a minimal reproduction, jpm/Node/JDK versions, OS/architecture, the exact command, and sanitized output. State whether the problem occurs from an installed npm archive or a source checkout. Include what changed and what you expected; do not attach a complete private project.

For suspected vulnerabilities, follow [SECURITY.md](https://github.com/CoderSerio/java-npm/security/policy).
