Debug Java applications systematically: JDWP remote debugging, jdb, VS Code and IntelliJ attach, debugging Maven/Gradle tests, Spring Boot and Quarkus dev mode, containers, breakpoints/logpoints, and reading stack traces. Use when the user needs to find the cause of a Java bug, exception, wrong behavior, or failing test, or asks how to attach a debugger.
Capabilities
Method
Reproduce deterministically, minimize, read the evidence (stack traces), test one falsifiable hypothesis with…
Attach a debugger (JDWP)
Always write the explicit 127.0.0.1:5005 on every JDK version: a bare address=5005 listens on all interfaces…
VS Code (Extension Pack for Java)
IntelliJ IDEA
Run | Edit Configurations | + | Remote JVM Debug; host 127.0.0.1, port 5005, debugger mode Attach
Getting started
Full instructionsExample command
Containers
docker run --rm -p 127.0.0.1:5005:5005 \Instructions: SKILL.mdv1.0.0
Java Debugging
Find the root cause of a Java defect with a reproducible, hypothesis-driven loop, and attach a debugger safely when logs are not enough.
Safety rules
- Bind JDWP to loopback only (
127.0.0.1). Never bind*:5005on a reachable network; use an SSH tunnel orkubectl port-forwardfor remote hosts. - Use
suspend=nfor running applications.suspend=yis acceptable only for short local test runs bound to loopback (waiting for the IDE to attach). Never leave a debug agent enabled on production; JDWP gives full code execution to whoever connects. - Do not attach a debugger to production without explicit user instruction. Prefer reproducing locally or use read-only diagnostics (see the
java-diagnosticsskill). JAVA_TOOL_OPTIONSis picked up by every JVM started in that environment (build tools, forked test JVMs, child processes), causingAddress already in useclashes. Prefer scoping the flag to the one process you want to debug.
Method
Reproduce deterministically, minimize, read the evidence (stack traces), test one falsifiable hypothesis with the least intrusive tool (log line or logpoint before breakpoints), then add a regression test and remove debug flags and temporary logging.
Version-dependent behavior (verified)
- Helpful NullPointerException messages (JEP 358) are off by default in JDK 14 (
-XX:+ShowCodeDetailsInExceptionMessages) and on by default from JDK 15 (JEP 358 documents the message format). Source: https://openjdk.org/jeps/358. - JDWP bare
address=5005binds all interfaces before JDK 9 and loopback from JDK 9 (see below). - Gradle
--debug-jvmpasses a bare address, so on JDK 8 it listens on all interfaces.
Attach a debugger (JDWP)
Start the JVM:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005 -jar app.jar
Always write the explicit 127.0.0.1:5005 on every JDK version: a bare address=5005 listens on all interfaces before JDK 9 and only on loopback from JDK 9. On JDK 8 and older, the host:port form may not be honored, so also restrict access with a firewall or tunnel.
Attach with jdb:
jdb -attach 127.0.0.1:5005
# stop in com.example.OrderService.place | stop at com.example.OrderService:42
# cont | next | step | locals | print order | where | catch java.lang.NullPointerException
VS Code (Extension Pack for Java)
.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Attach to JVM",
"request": "attach",
"hostName": "127.0.0.1",
"port": 5005
}
]
}
IntelliJ IDEA
Run | Edit Configurations | + | Remote JVM Debug; host 127.0.0.1, port 5005, debugger mode Attach. The dialog shows the matching JVM argument string.
Debug tests and frameworks
| Scenario | Command (port 5005) |
|---|---|
| Maven Surefire unit test | mvn test -Dmaven.surefire.debug -Dtest=OrderServiceTest |
| Maven Failsafe IT | mvn verify -Dmaven.failsafe.debug -Dit.test=OrderIT |
| Gradle test | gradle test --debug-jvm --tests '*OrderServiceTest' |
| Spring Boot (Maven) | mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005" |
| Spring Boot (Gradle) | Configure bootRun as below, then gradle bootRun (loopback, no suspend) |
| Quarkus dev mode | mvn quarkus:dev (debug port 5005 open by default; -Ddebug=5006 changes it, -Ddebug=false disables) |
Surefire/Failsafe debug mode and --debug-jvm suspend until a debugger attaches, which is fine for a local run. Surefire and Failsafe accept a custom agent string instead of the bare flag, e.g. -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=127.0.0.1:5005". Verified listeners on 127.0.0.1 (via lsof -nP -iTCP:5005 -sTCP:LISTEN) for Gradle 9.7 --debug-jvm, Maven Surefire 3.5 -Dmaven.surefire.debug and Quarkus 3.40 dev mode on JDK 26; Gradle 7.6.4, 8.0.2 (JDK 17), 8.5 (JDK 21) and 8.14.3 also listened on 127.0.0.1. Gradle passes a bare address=5005 (no host), so the bind address comes from the JDK: loopback on JDK 9+, but all interfaces (0.0.0.0:5005, checked in an eclipse-temurin:8-jdk container with Gradle 7.6.4 and 8.14.3) on JDK 8. Older Gradle/plugin versions were not tested; run the same lsof check and use an explicit loopback agent on shared networks or JDK 8.
Explicit Gradle configuration (Gradle 7.6+; debugOptions.host was added in 7.6; Kotlin DSL):
tasks.withType<Test> {
debugOptions { enabled.set(true); host.set("127.0.0.1"); port.set(5005); server.set(true); suspend.set(true) }
}
// BootRun extends JavaExec, not Test; configure it separately when the Boot plugin is applied.
tasks.named<JavaExec>("bootRun") {
debugOptions { enabled.set(true); host.set("127.0.0.1"); port.set(5005); server.set(true); suspend.set(false) }
}
Then run gradle test --tests '*OrderServiceTest' or gradle bootRun, without --debug-jvm (which enables suspension). Configure only the task you are debugging; do not run both listeners on port 5005 at once. For Gradle before 7.6, use jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005") on the target task instead (suspend=y for local tests), without also enabling debugOptions or --debug-jvm. On JDK 8 and older, retain the firewall/tunnel precaution above.
Containers
Publish the port to loopback only and let the JVM listen inside the container:
docker run --rm -p 127.0.0.1:5005:5005 \
-e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" my-app
Inside the container the agent must bind * for the port mapping to work, so JDWP (full code execution) is reachable by every other container on the same Docker network; the 127.0.0.1: mapping only blocks access from other hosts. Use this only on a developer machine where no untrusted containers share the network: run it on a dedicated user-defined network (not the shared default bridge) containing only this container, or keep the agent on 127.0.0.1 inside the container and reach it with docker exec/kubectl port-forward style forwarding instead of publishing it. For Kubernetes use kubectl port-forward pod/<name> 5005:5005 against a dev/staging pod only.
Common pitfalls
- Hot code replace only swaps method bodies; adding/removing methods or fields or changing signatures needs a restart (or Quarkus dev mode / Spring DevTools).
- Missing debug info: code compiled without
-gshows unavailable variables (Maven and Gradle include it by default). In lambdas, step into the lambda body. - Heisenbugs/races: pausing changes timing. Prefer logpoints, thread dumps, or JFR; suspend only the current thread, not all threads.
- Async and reactive code: stack traces show scheduler frames, not the caller. Use IDE async stack traces, correlation IDs, or Reactor
Hooks.onOperatorDebug()in dev only. - Virtual threads (JDK 21+): there can be thousands; use
jcmd <pid> Thread.dump_to_file -format=json file.jsonfor an overview. - Timeouts: long pauses can trip HTTP, DB, or heartbeat timeouts; raise them locally.
- toString() side effects: debugger evaluation calls
toString(), which may trigger lazy loading or mutate state.
Optional code-navigation aid
If the Copilot CLI lsp tool is configured (see the lsp-setup skill), go-to-definition, find-references, and call hierarchy help trace the execution path. It is optional; grep and reading code work as well.
References
- Reading stack traces
- For runtime symptoms (CPU, memory, deadlocks, slow startup) use the
java-diagnosticsskill.
Official tool docs (prefer them over this skill for the JDK in use; change 21 to your version): jcmd https://docs.oracle.com/en/java/javase/21/docs/specs/man/jcmd.html, JDK troubleshooting guide https://docs.oracle.com/en/java/javase/21/troubleshoot/.
Explore more skills
Browse all- Generate ImageGenerate images using AI. Use when asked to generate, create, or make images, textures, icons, sprites, artwork, visual…
- Anti UI SlopStop coding agents from shipping generic UI. Use UIZZE's 800,000+ real web and iOS screens to build product-specific…
- Security ReviewAI-powered codebase security scanner that reasons about code like a security researcher — tracing data flows,…
- Dotnet Best PracticesEnsure .NET/C# code meets best practices for the solution/project.
- Convert PDF to MdConverts PDF (.pdf) documents into Markdown so their contents can be accurately analyzed, summarized, searched, or…
- Meeting MinutesGenerate concise, actionable meeting minutes for internal meetings. Includes metadata, attendees, agenda, decisions,…
Security
Signing
SignedSLSA L2- Signed by
- skills-hub.ai distributor
- Method
- Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
- Key
- skills-hub-ed25519-2026-11
- Signed
Reviews (0)
More from GitHub Copilot
View source →You might also like
- GuideGitHub Copilot Browser Tools Are GA: AI Agents Now Verify Their Own Front-End WorkAs of July 1, 2026, GitHub Copilot's browser tools hit general availability in VS Code — letting AI coding agents drive a real browser to verify their own front-end changes. Here's what changed, how it works, and how to apply the same pattern in Claude Code and Cursor.7 min read
- GuideKimi K2.7 Code in GitHub Copilot: The First Open-Weight Model in a Mainstream AI Coding AssistantMoonshot AI's Kimi K2.7 Code landed in GitHub Copilot on July 1 — the first open-weight model in the five-lab model picker. MIT-licensed weights on Hugging Face, hosted on Azure, billed at GPT-5.4 mini tier pricing. Here's what it means for your workflow.7 min read
- GuideGitHub Copilot AI Credits: First-Week Reality Check (June 2026)On June 1, GitHub Copilot dropped flat-rate billing and switched to token-based AI Credits. One week in: some developers report bills jumping from $29 to $750/month. Here's the math, who gets hit hardest, and how to stay in budget.8 min read
Frequently asked questions about java-debugging
What does the java-debugging skill do?
Debug Java applications systematically: JDWP remote debugging, jdb, VS Code and IntelliJ attach, debugging Maven/Gradle tests, Spring Boot and Quarkus dev mode, containers, breakpoints/logpoints, and reading stack traces. Use when the user needs to find the cause of a Java bug, exception, wrong behavior, or failing test, or asks how to attach a debugger. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the java-debugging skill?
Run `npx @skills-hub-ai/cli install github-copilot-java-debugging` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/github-copilot-java-debugging/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does java-debugging work with?
java-debugging runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the java-debugging skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use java-debugging after installing it?
In Claude Code, type `/github-copilot-java-debugging` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the java-debugging skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.
Badge for your README
Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.
[](https://skills-hub.ai/skills/github-copilot-java-debugging)<a href="https://skills-hub.ai/skills/github-copilot-java-debugging"><img src="https://skills-hub.ai/api/badges/skill/github-copilot-java-debugging" alt="Install on Skills Hub"></a>More options in the badge docs.