This chapter describes how to start a JDB session in different ways.
JDB launch is the frequently used technique to start a JDB session.
There are two different ways to start a JDB session:
There are two different ways to start a JDB session:
- Starting JDB session by adding class (main class name) to it.
- Adding JDB to running JVM to start session.
Start a Session by Adding Class
The following command starts a JDB session:Syntax
\>jdb <classname>
Example
Let us assume we have a class named TestClass. The following command starts a JDB session from the TestClass.\>jdb TestClassIf you follow this command, it starts a new Java VM with any specified parameters. Thereafter it loads the class and stops it before executing the first statement of the class.
Start a Session by Adding JDB to a Running JVM
Given below is the syntax and example to start a JDB session by adding the JDB to a running JVM.Syntax
The following syntax is for JDB session:-agentlib:jdwp=transport=dt_shmem,address=,server=y,suspend=n
Example
Let us assume the main class name is TestClass and JVM allows the JDB to connect it later. The following is the command to add JDB to JVM:\>java -agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n TestClassNow you can attach the JDB to the JVM with the following command:
\> jdb -attach jdbconnNote: Here, the TestClass is not added to the JDB command, because JDB is connected to the running VM instead of launching a new one.
No comments:
Post a Comment