{
    "mode": "man",
    "parameter": "jdb",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/jdb/1/json",
    "generated": "2026-09-01T19:03:04Z",
    "synopsis": "jdb [options] [classname]  [arguments]\noptions\nCommand-line options. See Options.\nclassname\nName of the main class to debug.\narguments\nArguments passed to the main() method of the class.",
    "sections": {
        "NAME": {
            "content": "jdb - Finds and fixes bugs in Java platform programs.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "jdb [options] [classname]  [arguments]\n\n\noptions\nCommand-line options. See Options.\n\nclassname\nName of the main class to debug.\n\narguments\nArguments passed to the main() method of the class.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  Java  Debugger (JDB) is a simple command-line debugger for Java classes. The jdb command\nand its options call the JDB.  The  jdb  command  demonstrates  the  Java  Platform  Debugger\nArchitecture  (JDBA)  and provides inspection and debugging of a local or remote Java Virtual\nMachine    (JVM).    See    Java     Platform     Debugger     Architecture     (JDBA)     at\nhttp://docs.oracle.com/javase/8/docs/technotes/guides/jpda/index.html\n\nSTART A JDB SESSION\nThere  are  many  ways  to  start  a JDB session. The most frequently used way is to have JDB\nlaunch a new JVM with the  main  class  of  the  application  to  be  debugged.  Do  this  by\nsubstituting  the  jdb command for the java command in the command line. For example, if your\napplication's main class is MyClass, then use the following command to debug it under JDB:\n",
            "subsections": [
                {
                    "name": "jdb MyClass",
                    "content": "When started this way, the jdb command calls a second  JVM  with  the  specified  parameters,\nloads the specified class, and stops the JVM before executing that class's first instruction.\n\nAnother  way  to  use  the  jdb  command is by attaching it to a JVM that is already running.\nSyntax for starting a JVM to which the jdb command attaches when the JVM  is  running  is  as\nfollows. This loads in-process debugging libraries and specifies the kind of connection to be\nmade.\n"
                },
                {
                    "name": "java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n MyClass",
                    "content": "You can then attach the jdb command to the JVM with the following command:\n"
                },
                {
                    "name": "jdb -attach 8000",
                    "content": "The  MyClass  argument  is not specified in the jdb command line in this case because the jdb\ncommand is connecting to an existing JVM instead of launching a new JVM.\n\nThere are many other ways to connect the debugger to a JVM, and all of them are supported  by\nthe  jdb  command.  The  Java  Platform Debugger Architecture has additional documentation on\nthese connection options.\n\nBASIC JDB COMMANDS\nThe following is a list of the basic jdb commands. The JDB supports other commands  that  you\ncan list with the -help option.\n\nhelp or ?\nThe  help  or  ?  commands  display  the  list  of  recognized  commands  with a brief\ndescription.\n\nrun    After you start JDB and set breakpoints, you can use the run command  to  execute  the\ndebugged  application.  The  run command is available only when the jdb command starts\nthe debugged application as opposed to attaching to an existing JVM.\n\ncont   Continues execution of the debugged application  after  a  breakpoint,  exception,  or\nstep.\n\nprint  Displays  Java  objects  and  primitive  values.  For variables or fields of primitive\ntypes, the actual value is printed. For objects, a short description is  printed.  See\nthe dump command to find out how to get more information about an object.\n\nNote:  To  display  local variables, the containing class must have been compiled with\nthe javac -g option.\n\nThe print command supports many simple Java expressions including  those  with  method\ninvocations, for example:\n\nprint MyClass.myStaticField\nprint myObj.myInstanceField\nprint i + j + k (i, j, k are primities and either fields or local variables)\nprint myObj.myMethod() (if myMethod returns a non-null)\nprint new java.lang.String(\"Hello\").length()\n\n\n\ndump   For primitive values, the dump command is identical to the print command. For objects,\nthe  dump command prints the current value of each field defined in the object. Static\nand instance  fields  are  included.  The  dump  command  supports  the  same  set  of\nexpressions as the print command.\n\nthreads\nList  the  threads  that  are currently running. For each thread, its name and current\nstatus are printed and an index that can be used in other commands. In  this  example,\nthe  thread index is 4, the thread is an instance of java.lang.Thread, the thread name\nis main, and it is currently running.\n\n4. (java.lang.Thread)0x1 main      running\n\n\n\nthread Select a thread to be the current thread. Many jdb commands are based on  the  setting\nof  the current thread. The thread is specified with the thread index described in the\nthreads command.\n\nwhere  The where command with no arguments  dumps  the  stack  of  the  current  thread.  The\nwhereall  command  dumps  the  stack  of  all threads in the current thread group. The\nwherethreadindex command dumps the stack of the specified thread.\n\nIf the current thread is suspended either through an event such  as  a  breakpoint  or\nthrough the suspend command, then local variables and fields can be displayed with the\nprint  and  dump  commands.  The  up and down commands select which stack frame is the\ncurrent stack frame.\n\nBREAKPOINTS\nBreakpoints can be set in JDB at line numbers or at the first instruction of  a  method,  for\nexample:\n\n• The  command  stop  at MyClass:22 sets a breakpoint at the first instruction for line 22 of\nthe source file containing MyClass.\n\n• The command stop in java.lang.String.length sets a  breakpoint  at  the  beginning  of  the\nmethod java.lang.String.length.\n\n• The  command  stop  in MyClass.<clinit> uses <clinit> to identify the static initialization\ncode for MyClass.\n\nWhen a method is overloaded, you must also specify its argument  types  so  that  the  proper\nmethod  can be selected for a breakpoint. For example, MyClass.myMethod(int,java.lang.String)\nor MyClass.myMethod().\n\nThe clear command removes breakpoints using the following syntax: clear MyClass:45. Using the\nclear or stop command with no argument displays a list of all breakpoints currently set.  The\ncont command continues execution.\n\nSTEPPING\nThe step command advances execution to the next line whether it is in the current stack frame\nor a called method. The next command advances execution to the next line in the current stack\nframe.\n\nEXCEPTIONS\nWhen  an  exception  occurs for which there is not a catch statement anywhere in the throwing\nthread's call stack, the JVM typically prints an exception  trace  and  exits.  When  running\nunder  JDB,  however, control returns to JDB at the offending throw. You can then use the jdb\ncommand to diagnose the cause of the exception.\n\nUse the catch command to cause the debugged application to stop at other  thrown  exceptions,\nfor  example:  catch java.io.FileNotFoundException or catchmypackage.BigTroubleException. Any\nexception that is an instance of the specified class or subclass stops the application at the\npoint where it is thrown.\n\nThe ignore command negates the effect of an earlier catch command. The  ignore  command  does\nnot cause the debugged JVM to ignore specific exceptions, but only to ignore the debugger.\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "When you use the jdb command instead of the java command on the command line, the jdb command\naccepts  many  of  the  same  options  as  the java command, including -D, -classpath, and -X\noptions. The following list contains additional options that are accepted by the jdb command.\n\nOther options are supported to provide alternate mechanisms for connecting  the  debugger  to\nthe JVM it is to debug. For additional documentation about these connection alternatives, see\nJava           Platform           Debugger           Architecture          (JPDA)          at\nhttp://docs.oracle.com/javase/8/docs/technotes/guides/jpda/index.html\n",
            "subsections": [
                {
                    "name": "-help",
                    "content": "Displays a help message.\n\n-sourcepath dir1:dir2: . . .\nUses the specified path to search for source files in  the  specified  path.  If  this\noption is not specified, then use the default path of dot (.).\n\n-attach address\nAttaches the debugger to a running JVM with the default connection mechanism.\n\n-listen address\nWaits for a running JVM to connect to the specified address with a standard connector.\n"
                },
                {
                    "name": "-launch",
                    "content": "Starts  the  debugged  application immediately upon startup of JDB. The -launch option\nremoves the need for the run command. The debugged application is  launched  and  then\nstopped  just  before  the initial application class is loaded. At that point, you can\nset any necessary breakpoints and use the cont command to continue execution.\n"
                },
                {
                    "name": "-listconnectors",
                    "content": "List the connectors available in this JVM.\n\n-connect connector-name:name1=value1\nConnects to the target JVM with the named connector and listed argument values.\n"
                },
                {
                    "name": "-dbgtrace [_flags_]",
                    "content": "Prints information for debugging the jdb command.\n"
                },
                {
                    "name": "-tclient",
                    "content": "Runs the application in the Java HotSpot VM client.\n"
                },
                {
                    "name": "-tserver",
                    "content": "Runs the application in the Java HotSpot VM server.\n"
                },
                {
                    "name": "-J_option_",
                    "content": "Passes option to the JVM, where  option  is  one  of  the  options  described  on  the\nreference  page  for  the  Java  application launcher. For example, -J-Xms48m sets the\nstartup memory to 48 MB. See java(1).\n"
                }
            ]
        },
        "OPTIONS FORWARDED TO THE DEBUGGER PROCESS": {
            "content": "-v -verbose[:class|gc|jni]\nTurns on verbose mode.\n\n-Dname=value\nSets a system property.\n\n-classpath dir\nLists directories separated by colons in which to look for classes.\n",
            "subsections": [
                {
                    "name": "-X_option_",
                    "content": "Nonstandard target JVM option.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "• javac(1)\n\n• java(1)\n\n• javah(1)\n\n• javap(1)\n\nJDK 8                                     21 November 2013                                    jdb(1)",
            "subsections": []
        }
    },
    "summary": "jdb - Finds and fixes bugs in Java platform programs.",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Displays a help message. -sourcepath dir1:dir2: . . . Uses the specified path to search for source files in the specified path. If this option is not specified, then use the default path of dot (.). -attach address Attaches the debugger to a running JVM with the default connection mechanism. -listen address Waits for a running JVM to connect to the specified address with a standard connector."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Starts the debugged application immediately upon startup of JDB. The -launch option removes the need for the run command. The debugged application is launched and then stopped just before the initial application class is loaded. At that point, you can set any necessary breakpoints and use the cont command to continue execution."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "List the connectors available in this JVM. -connect connector-name:name1=value1 Connects to the target JVM with the named connector and listed argument values."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints information for debugging the jdb command."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Runs the application in the Java HotSpot VM client."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Runs the application in the Java HotSpot VM server."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Passes option to the JVM, where option is one of the options described on the reference page for the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. See java(1)."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "javac",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/javac/1/json"
        },
        {
            "name": "java",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/java/1/json"
        },
        {
            "name": "javah",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/javah/1/json"
        },
        {
            "name": "javap",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/javap/1/json"
        }
    ]
}