# java-manager — Agent guide
## Commands (run in order: check → test → clippy → fmt)
| `cargo check` | Verify compilation (fast) |
| `cargo test` | Run all tests (unit tests live in `#[cfg(test)]` in source files; no `tests/` dir yet) |
| `cargo clippy -- -D warnings` | Lint with warnings as errors |
| `cargo fmt --check` | Check formatting (rustfmt defaults) |
| `cargo run --example <name>` | Run an example (`quick-start`, `java-home`, `search`, `execute`) |
Make shortcuts (see `Makefile` for the full list):
- `make check`, `make build`, `make build.release`
- `make example-run FILE=<name>` — builds + runs a debug example
- `make example-java-build` — runs `examples/java/build.sh`
## Architecture
**Library crate** (no binary), **Rust edition 2024**.
| `lib.rs` | Re-exports the public API |
| `info.rs` | `JavaInfo` struct: metadata from `release` file + `java -version` |
| `search.rs` | `quick_search()` (PATH walk) + `deep_search()` (Everything SDK only on Windows, or `full_search` on Linux) + `full_search()` (registry + BFS + MS Store + `where` on Windows; walkdir + keywords on Linux) |
| `local.rs` | `java_home()` — reads `JAVA_HOME` env var |
| `execute.rs` | `JavaRunner` (builder) + `JavaRedirect` for process execution |
| `error.rs` | `JavaError` enum with `From<io::Error>` |
Platform-specific deep search:
- **Windows (deep_search)**: uses Everything SDK (Everything must be installed + running)
- **Linux (deep_search)**: delegates to `full_search`
- **full_search (Windows)**: registry + keyword BFS + Microsoft Store + `where` command (no Everything dep)
- **full_search (Linux)**: walks `/usr/lib/jvm`, `/usr/java`, `/opt`, `/usr/local` + `~/.minecraft/runtime` via `walkdir` with keyword filtering
## Notable deps
- Core: `glob`, `is_executable`, `shell-words`
- Dev: `tempfile` (for I/O tests)
- Windows-only: `everything-sdk`, `winreg`, `windows`
- Linux-only: `walkdir`
## Repo quirks
- No CI workflows, no pre-commit hooks.
- `user.mk` is a git-automation helper in `.gitignore` (user-local, not committed).
- No test functions exist yet — add `#[cfg(test)] mod tests { ... }` in source files.
- `full_search()` is also exported from `lib.rs` (alongside `quick_search` and `deep_search`).
- `JavaInfo::new()` accepts a path to a `java` executable or a `JAVA_HOME` dir.
- `JavaRunner` requires either `.jar(...)` or `.main_class(...)` before `.execute()`.
- `format_memory()` rounds to nearest MiB/GiB for `-Xms`/`-Xmx` flags.