# jdx source

IDE equivalent: Open the file / decompile

Show a type's source: the verbatim file with 1-based line numbers plus provenance (artifact, file, lines). Takes a type reference (e.g. 'com.example.Point', 'Gson'). Slice it with --lines A:B or center on a member with --around '<type>#<member>' --context N. Without paired sources the query names the decompiler tasks instead of guessing. Exits 1 when the type or its sources are unknown, 2 when ambiguous, 4 when the workspace cannot be resolved.

## Usage

```text
jdx source [<options>] <ref>
```

## Example

```console
$ jdx source com.google.gson.JsonNull --lines 17:45 --coord com.google.code.gson:gson:2.14.0
com.google.gson.JsonNull
  source: gson-2.14.0-sources.jar · com/google/gson/JsonNull.java:17-45
package com.google.gson;

/**
 * A class representing a JSON {@code null} value.
 *
 * @author Inderjeet Singh
 * @author Joel Leitch
 * @since 1.2
 */
public final class JsonNull extends JsonElement {
  /**
   * Singleton for {@code JsonNull}.
   *
   * @since 1.8
   */
  public static final JsonNull INSTANCE = new JsonNull();

  /**
   * Creates a new {@code JsonNull} object.
   *
   * @deprecated Deprecated since Gson version 1.8, use {@link #INSTANCE} instead.
   */
  @Deprecated
  public JsonNull() {
    // Do nothing
  }

  /**
… 3 more lines (run it yourself to see them all)
```

## Options

| Option | Description |
|---|---|
| `--lines=<text>` | Show only lines A:B (1-based inclusive, e.g. --lines 100:180). Mutually exclusive with --around. |
| `--around=<text>` | Center the slice on a member reference (e.g. --around 'Point#getX()'); --context N expands it each side. |
| `--context=<int>` | Surrounding source lines shown each side of the --around member (default 0). |
| `--line-numbers` | Prefix each shown line with its 1-based number. |
| `--max-lines=<int>` | Maximum source lines shown (default 200); the rest become a truncation footer. |
| `--engine=(vineflower\|javap)` | Disassembly engine: vineflower forces reconstruction even when sources are paired (default serves sources, falling back to vineflower); javap shows the raw bytecode instead. |
| `--jars=<text>` | Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots. |
| `-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` | Emit machine-readable JSON instead of human-readable text (same information, D-007). |
| `--no-color` | Disable ANSI colors even on a TTY (piped output is always plain). |
| `--no-daemon` | Force in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1). |
| `-h, --help` | Show this message and exit |

## Arguments

| Argument | Description |
|---|---|
| `<ref>` | Type reference to show the source of (full or short form). |

## Full help text

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

  Show a type's source: the verbatim file with 1-based line numbers plus provenance (artifact, file, lines). Takes a type reference (e.g. 'com.example.Point', 'Gson'). Slice it with --lines A:B or center on a member with --around '<type>#<member>' --context N. Without paired sources the query names the decompiler tasks instead of guessing. Exits 1 when the type or its sources are unknown, 2 when ambiguous, 4 when the workspace cannot be resolved.

Options:
  --lines=<text>               Show only lines A:B (1-based inclusive, e.g. --lines 100:180). Mutually exclusive with --around.
  --around=<text>              Center the slice on a member reference (e.g. --around 'Point#getX()'); --context N expands it each side.
  --context=<int>              Surrounding source lines shown each side of the --around member (default 0).
  --line-numbers               Prefix each shown line with its 1-based number.
  --max-lines=<int>            Maximum source lines shown (default 200); the rest become a truncation footer.
  --engine=(vineflower|javap)  Disassembly engine: vineflower forces reconstruction even when sources are paired (default serves sources, falling back to vineflower); javap shows the raw bytecode instead.
  --jars=<text>                Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots.
  -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                       Emit machine-readable JSON instead of human-readable text (same information, D-007).
  --no-color                   Disable ANSI colors even on a TTY (piped output is always plain).
  --no-daemon                  Force in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1).
  -h, --help                   Show this message and exit

Arguments:
  <ref>  Type reference to show the source of (full or short form).
```

## Learn more

Guide: [Reading code](https://mohammadmd1383.github.io/jdx/docs/reading-code/) · [All commands](https://mohammadmd1383.github.io/jdx/docs/reference/)
