1

Is there any way to get a list of all current objects and local variables when debugging a java program? Seems JDB doesn't offer such functionality. I only can inspect vars and objects if I know the name of them.

My aim is to step through any line of code from the beginning while being able to see at any time which objects live in memory and which local variables does my current method have.

Vetterjack
  • 2,227
  • 4
  • 19
  • 31

1 Answers1

3

The command for listing the local variables is locals.

If you launch a jdb session and type help, it says:

locals                    -- print all local variables in current stack frame
Jeremy
  • 22,188
  • 4
  • 68
  • 81
  • Thanks a lot! I only had a look at the [oracle docs](http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html) – Vetterjack Mar 07 '17 at 20:46
  • `javac -g Xxx.class` first or you will get `Local variable information not available. Compile with -g to generate variable information`. – schemacs Jul 15 '21 at 06:47