Java - Debugger (jdb) (local|remote)

> Procedural Languages > Java

1 - About

Debugger in Java

When you enable debugging, you enable both local and remote debugging.

The Java Platform Debugger Architecture (JPDA) is the architecture designed for use by debuggers and debugger-like tools. It consists of two programming interfaces and a wire protocol.

3 - Jdb

The jdb utility is included in the JDK release as the example command-line debugger. The jdb command demonstrates the Java Platform Debugger Architecture (JDBA)

Jdb doc

Advertising

4 - Connect the debugger to a JVM

There is a lot of way to connect the debugger to the JVM.

4.1 - Java

  • loading in-process debugging libraries and specifiing the kind of connection to be made.
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n MyClass

where:

  • suspend=y/n , controls whether the JVM should wait for the debugger to attach before starting up.

4.2 - Attach

jdb -attach 8000

5 - Client

5.1 - Intellij

Advertising

6 - Server

6.1 - Maven

  • Maven 2.0.8 or newer: run the “mvnDebug” command in place of “mvn”
  • Maven <2.0.8: uncomment the following mvn.bat line
@REM set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

See Maven: Enable remote debugging command line option

X options are options of the JRockit JVM.

7 - Jdwp

Java Debug Wire Protocol (JDWP) defines the format of information and requests transferred between the debuggee process and the debugger front-end.

8 - Documentation / Reference

lang/java/debugger.txt · Last modified: 2018/12/25 17:50 by gerardnico