From the Java SE Downloads page, you can download JDK and JavaFX demos and examples. When you download and unzip this package, the demo/jpda
directory contains source code and documentation for three applications written using the Java Debug Interface (JDI) of the Java Platform Debugger Architecture (JPDA). They are provided as educational tools and as starting points for debugger development.
In increasing order of complexity:
Trace is in the trace
directory. Jdb and Javadt
share a package, and are in the debug
directory.
Your classpath must include the JDI Library code, which is in
lib/tools.jar
directory of the JDK. (Note that
tools.jar is not in the Java Runtime Environment; it is
only in the JDK.) This is needed for both compiling the
example code and executing it. For information on how to set the
classpath, see the JDK Tools and Utilities documentation.