Debugging Java applications
To debug Java™ programs, you can use the Java Debugger (JDB) application or other debuggers that communicate by using the Java Platform Debugger Architecture (JPDA) that is provided by the SDK for the operating system.
Information about problem diagnosis using Java can be found in Troubleshooting and support.
Note: On AIX® systems, the SDK includes a Plug-in for the
AIX debugger, DBX.
Although the DBX plug-in is supplied as part of the SDK, it is not supported. However, IBM® will accept bug
reports.
The Java Debugger
The JDB is included in the SDK. The debugger is started with the jdb command; it attaches to the JVM using JPDA.
- To debug a Java application:
-
- Start the JVM with the following options:
- On Windows
systems:
java -agentlib:jdwp=transport=dt_shmem,server=y,address=<port> <class> - On other
systems:
java -agentlib:jdwp=transport=dt_socket,server=y,address=<port> <class>
The JVM starts, but suspends execution before it starts the Java application.
- On Windows
systems:
- In a separate session, you can attach the debugger to the JVM:
The debugger will attach to the JVM, and you can now issue a range of commands to examine and control the Java application; for example, type run to allow the Java application to start.jdb -attach <port>
- Start the JVM with the following options:
- To debug Java applications running on remote workstations:
- JPDA uses a TCP/IP socket to connect to the remote JVM.
- Start the JVM with the following options:
- On Windows
systems:
java -agentlib:jdwp=transport=dt_shmem,server=y,address=<port> <class> - On other
systems:
java -agentlib:jdwp=transport=dt_socket,server=y,address=<port> <class>
The JVM starts, but suspends execution before it starts the Java application.
- On Windows
systems:
- Attach the debugger to the remote JVM:
- On Windows
systems:
jdb -connect com.sun.jdi.SocketAttach:hostname=<host>,port=<port> - On other
systems:
jdb -attach <host>:<port>
- On Windows
systems:
- Start the JVM with the following options:
- For further information:
-
- For more information about JDB options, type:
jdb -help - For more information about JDB commands:
- Type
jdb - At the jdb prompt, type
help
- Type
- For more information about JDB and JPDA and their usage, see:
- For more information about JDB options, type: