Hello all,
I have a program running with this command 'jdb prog'. It was compiled with 'javac -g prog.java'. The program when running normally asks for input, 1st it asks for a number then it asks for a second number. When running in jdb it still asks for input so I type '5', for exmple, and jdb says "Unrecognized command: '5'. Try help...."
How do I tell jdb to send a number or string for that matter to the running program?

thank you,

7 Years
Discussion Span
Last Post by youngstorm

jdb says? or prog says? does prog accept arguments when called or when during execution?

do you actually call run to start prog execution?


I run the program like this 'java prog'. When I run do, 'prog' asks for 2 numbers, 1 after the other. Then it does a computation on them.

I am trying to debug my program. I use jdb. I start it with 'jdb prog'. While in jdb, I tell it to start executing prog by typing 'run'. jdb runs prog and prog asks for a number. It will wait on that number. I type a number but jdb thinks it is a command. and replies "Unrecognized command: '5'. Try help....". I need to tell jdb to pass the number I typr to prog so it will continue execution.

I hope this clears things up and has not made you more confused.



if you are debugging your app, i assume you have some breakpoints defined. are you hitting one of these breakpoints and not knowing it? make sure you step past any breakpoints you may have. if you are querying for user inputs, it would be logical to have prompts so the user knows when to input values too.


I ran it without breakpoints, just get a sense of what it is doing. I'm playing with breakpoints now. It does use prompts. When jdb runs prog, it displays the prompt to enter a number. So, I type in a number and jdb complains. It thinks the number I type is a jdb command.


You'll probably have to attach the debugger from a separate command window.
From the Sun doc on jdb:

For example, the following command will run the MyClass application, and allow jdb to connect to it at a later time.

% java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n MyClass

You can then attach jdb to the VM with the following commmand:

% jdb -attach 8000

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.