# jdx batch

IDE equivalent: Many queries, one process (NDJSON in/out)

Answer many queries in one process: read NDJSON RpcRequest lines ({"command":"members","query":"…","params":{…}}) from stdin, print one --json envelope per line on stdout. Per-query failures ride their own envelope and never abort the stream; the exit code is the maximum query exit code. Output is always envelopes (--json is accepted and ignored). Roots resolve once from --jars/--src/-w/--no-jdk/--coord/--repo/--fetch. Example: echo '{"command":"show","query":"java.util.Map"}' | jdx batch.

## Usage

```text
jdx batch [<options>]
```

## Example

```console
$ echo '{"command":"show","query":"java.util.Map"}' | jdx batch
{"jdx":1,"ok":true,"command":"show","query":"java.util.Map","result":{"kind":"interface","declaration":"public abstract interface Map","modifiers":["public","abstract"],"interfaces":[],"counts":{"constructors":0,"methods":39,"fields":0}},"warnings":[],"provenance":[{"artifact":"java.base","origin":"jrt"}]}
```

## Options

| Option | Description |
|---|---|
| `--jars=<text>` | Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots. |
| `--src=<text>` | Source-dir roots: directories of .java/.kt files scanned textually for whole-word mentions (repeatable). Merge in front of the selected workspace's stored srcs. |
| `-w, --workspace=<text>` | Use a named workspace (see jdx ws). Explicit --jars merge in front of it. |
| `--no-jdk` | Do not include the running JDK's stdlib (included by default). |
| `--coord=<text>` | Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace. |
| `--repo=<text>` | Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL. |
| `--fetch` | Allow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only. |
| `--json` | Accepted and ignored: batch output is always the --json envelope, one per line. |
| `-h, --help` | Show this message and exit |

## Full help text

```console
$ jdx batch --help
Usage: jdx batch [<options>]

  Answer many queries in one process: read NDJSON RpcRequest lines ({"command":"members","query":"…","params":{…}}) from stdin, print one --json envelope per line on stdout. Per-query failures ride their own envelope and never abort the stream; the exit code is the maximum query exit code. Output is always envelopes (--json is accepted and ignored). Roots resolve once from --jars/--src/-w/--no-jdk/--coord/--repo/--fetch. Example: echo '{"command":"show","query":"java.util.Map"}' | jdx batch.

Options:
  --jars=<text>           Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots.
  --src=<text>            Source-dir roots: directories of .java/.kt files scanned textually for whole-word mentions (repeatable). Merge in front of the selected workspace's stored srcs.
  -w, --workspace=<text>  Use a named workspace (see jdx ws). Explicit --jars merge in front of it.
  --no-jdk                Do not include the running JDK's stdlib (included by default).
  --coord=<text>          Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace.
  --repo=<text>           Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL.
  --fetch                 Allow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only.
  --json                  Accepted and ignored: batch output is always the --json envelope, one per line.
  -h, --help              Show this message and exit
```

## Learn more

Guide: [MCP, daemon, HTTP & batch](https://mohammadmd1383.github.io/jdx/docs/serving/) · [All commands](https://mohammadmd1383.github.io/jdx/docs/reference/)
