Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 499675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:00:35+00:00 2026-05-13T06:00:35+00:00

Debugging my code with Java’s jdb. Am stuck at a point where my program

  • 0

Debugging my code with Java’s jdb. Am stuck at a point where my program expects command-line input, but jdb intercepts it as a jdb command.

How do I tell jdb to pass through text to the running program?

Version:

C:\Documents and Settings\*snip*>java -showversion
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

Compile:

javac -g LZWDecompress.java

jdb.ini:

stop in LZWDecompress.decompress
run
monitor list

This is what happens:

Initializing jdb ...
*** Reading commands from C:\Documents and Settings\*snip*\jdb.ini
Deferring breakpoint LZWDecompress.decompress.
It will be set after the class is loaded.
> run LZWDecompress
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
> > >
VM Started: Set deferred breakpoint LZWDecompress.decompress
File to be decompressed: 

At the prompt above, I enter “test”, and receive this response:

...
VM Started: Set deferred breakpoint LZWDecompress.decompress
File to be decompressed: test
Unrecognized command: 'test'.  Try help...
>

Here is the code from function main(…), written by our instructor, not me:

public static void main(String[] args) throws IOException {    
    short [] source; 
    int dlen; 
    int sz;
    byte [] decompressed;
    BufferedReader br;
    DataInputStream In;
    FileInputStream FI;
    FileOutputStream FO;
    InputStreamReader isr;
    String cfnm;
    String sfnm;

    source = new short[INPUT_FILE_IO_BUFFER_SIZE];
    decompressed = new byte[OUTPUT_FILE_IO_BUFFER_SIZE];

    isr = new InputStreamReader(System.in);
    br = new BufferedReader(isr);
    System.out.print("File to be decompressed: ");
    System.out.flush(); 
    sfnm = br.readLine();
    System.out.print("Name of the decompressed file: ");
    System.out.flush(); 
    cfnm = br.readLine();
    FI = new FileInputStream(sfnm);
    In = new DataInputStream(FI);
    FO = new FileOutputStream(cfnm);
    for (sz=0; true; ++sz) {
        try { source[sz] = In.readShort();
        } catch (EOFException e) { break;
        } catch (Exception e) { System.out.print(e.toString()); 
        }
    }
    dlen = decompress(source, sz, decompressed);
    FO.write(decompressed, 0, dlen);
    FO.close(); 
}  // end main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:00:36+00:00Added an answer on May 13, 2026 at 6:00 am

    Hmmm…this post seems to indicate I need to run the program and then attach the debugger to it. For example:

    % java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n LZWDecompress
    
    % jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8000
    

    Not immediately obvious how I get the program to stop after passing by the user input functions.

    Is this the preferred way to do this?

    Update: attach and configure jdb (for example, breakpoints) once the running program prompts for user input. Once jdb is configured, provide input to the running program. jdb then takes over program execution in the second window. 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 261k
  • Answers 261k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer One approach is to write a C template for your… May 13, 2026 at 11:34 am
  • Editorial Team
    Editorial Team added an answer You only have 2 things wrong with this code. 1)… May 13, 2026 at 11:34 am
  • Editorial Team
    Editorial Team added an answer You could send a 204 no content. Google seem to… May 13, 2026 at 11:34 am

Related Questions

I'm following the sample code in CFNetwork Programming Guide , specifically the section on
I'm new to Java and I need some advice/information on how to debug my
Been hitting my head on the wall before as I don't make any test
I have to work on several VB6 legacy projects and despite some good VB6
I'm trying to use the @Test(expected = RuntimeException.class) annotation in order to test for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.