views:

34

answers:

2

I'm learning JDB and running into a bit of a paradox. After starting JDB (with "jdb ClassName") most tutorials will tell me to type

> methods ClassName

to see a list of available methods so that I can set my breakpoints. If I do that, JDB replies

Command 'methods' is not valid until the VM is started with the 'run' command

Of course, if I say "run" before setting any breakpoints, it runs straight through; not very helpful. The only thing I can conclude is that jdb expects you to set your breakpoints blind, but this seems like such a gross oversight, I'm holding out that I'm simply missing a command.

Many thanks!! Joyce

+1  A: 

If it's your own program you're debugging, I'd think you'd know the class names!

If it's a program for which you don't have the source code, then to run it you must know the class name containing main(). If it's in a jar started with java -jar, the name of that class is in the manifest inside the jar.

But in fact you're running jdb ClassName, so you know you'll be running method ClassName.main(). Right?

If it's a servlet in a web service, the class of the servlet is in web.xml.

So in any of those cases you should at least be able to get the very first method. Once there, you can find the rest.

Carl Smotricz
A: 

I suspected this might be the way it was done. I still think having the list available from the get go would've been a more elegant design, but this works well enough. Thanks for the reply!

Joyce

Joyce