I'm a bit confused by JDB. Being fairly good at using GDB, I'm aware of the various simple commands used to control the execution, i.e. start, run, cont, step, stepi, break, etc. but there are a number of (in my opinion) unusual differences.
If I wish to start an application (as opposed to running it, so I can step it from the start), instinctively, I type jdb MyApp
and then start
. I get an unrecognized command error. Reading the JDB help gives me no indication at all of a start command or its equivalent. So, I try step
- that doesn't work either; I am told that I need to start the Java VM with the run
command!
Clearly, it must be possible, because there is a step
command explained in the help. So, I figure that maybe I can type run
and very quickly press ctrl+c
to interrupt it as, in GDB, this stops the execution. Instead, it just quits JDB.
I've tried googling this, to no avail. I hope I'm not being totally blind stupid!
Rant over: how on earth do you just start running a java application in JDB so that you can step it, from the start?
I have just started to use JDB
as a debugger. There are good instructions that can be found here. To answer some of your questions:
jdb
, at the command prompt, type jdb <name of main class>
run
stop at <class>:<line no.>
cont
As I said, I have just started to use jdb
just now. There are, I am sure, better ways to do the above and I will post here should I get to know more myself.
HTH.
The problem is the VM hasn't launched, which is why you can't step into the first line. The solution is to start JDB with "-launch" as a command line argument. From there you can type "step" or "cont" to start debugging from the start.
The best bit is it only takes a second and doesn't require installing an IDE :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With