debugging - How do I pass console input to a running Java program instead of to jdb? -
Debugging my code with Java's JDB is stuck at a point where my program is expected to command-line input , But JDB marks it as jdb command.
How do I tell jdb to go through text in the running program?
Version:
C: \ Documents and Settings \ * Harvesting * & gt; Java-Shower Java version "1.6.0_17" Java (TM) SE runtime environment (1.6.0_17-B4 build) Java HotSpot (TM) client VM (build 14.3-B01, mixed mode, sharing)
compile:
javac -g, LZWDecompress.java
jdb.ini:
Stop the LZWDecompress.decompress run monitor list
This is what happens:
Starting jdb ... *** commands from C Reading: \ Documents and Settings \ * Snip * \ jdb.ini Suspended Point LZWDecompress.decompress It will be set after the load. & Gt; Press LZWDepress to run java.lang.Throwable set set uncaught java.lang.Throwable & gt; & Gt; & Gt; VM started: Set deferred breakpoint File to be dezmodrod:
At the above prompt, I enter "test", and receive this response:
< Pre> ... VM started: Set deferred breakpoint to uncompress the LZWDecompress.decompress file: test unrecognized command: Try 'test' help ... & gt;
The function here is the code from main (...), which is written by our instructor, not me:
public static zero main (string [] Argos) IOException {short [] throws the source; Int Delan; Int sz; Byte [] Uncompressed; Bufrederer br; DataInputStream In; FileInputStream FI; FileOutputStream FO; InputStreamReader isr; String cfnm; String SFN; Source = new small [INPUT_FILE_IO_BUFFER_SIZE]; Exploded = new byte [OUTPUT_FILE_IO_BUFFER_SIZE]; Isr = new InputStreamReader (System.in); Br = new buffed reader (ISR); System.out.print ("to uncompress the file:"); System.out.flush (); Sfnm = br.readLine (); System.out.print ("Disintegrated file name:"); System.out.flush (); Cfnm = br.readLine (); FI = new FileInputStream (sfnm); = New dataInput in the stream (FI); FO = New FileAutputStream (CFNM); For (sz = 0; true; ++ sz) {try {source [sz] = in.readShort (); } Hold (EOFException e) {break; } Hold (exception e) {System.out.print (e.toString ()); }} Dlen = decompress (source, sz, decompressed); Fo. Written (uncompressed, 0, delan); FO.close (); } // end main ()
hmmm ... to point me to it It seems to run the program and then attach it to the debugger. For example:
% java -Xdebug -Xrunjdwp: transport = dt_socket, address = 8000, server = y, suspended = n LZW Decompress% jdb-connect com.sun.jdi.SocketAttach: Hostname = local afost, port = 8000
How do I immediately clear how to stop the program after going through the user input function.
Is this the preferred way of doing this?
Update : Attach and configure JDB (example breakpoint) after prompting the running program for user input Once jdb is configured, input to the running program is provided Please. JDB then takes the program execution in the second window. : D
Comments
Post a Comment