Results 1 to 5 of 5
  1. #1
    flubbernugget is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default Using the Scanner Class with jdb

    Is there any way to debug a program that uses the class? The problem is that when the nextInt() member method executes, it waits for input from the console. However, my console input is being read by the jdb program instead of the class I created.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    The Scanner class reads from a Stream. What Stream you get it to read from is upto you.

  3. #3
    flubbernugget is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default

    So, is there any way for the class I compiled to read my input instead of the jdb?

    If it makes it anymore clear, this is the problem I get when trying to use the console debugger.
    Java Code:
    C:\Users\Ryan>jdb
    Initializing jdb ...
    > stop at PrintCalendar:67
    Deferring breakpoint PrintCalendar:67.
    It will be set after the class is loaded.
    > run PrintCalendar
    run  PrintCalendar
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >
    VM Started: Set deferred breakpoint PrintCalendar:67
    [B][I]Enter a year: 123[/I][/B][I][/I]
    [B][I]Unrecognized command: '123'.  Try help...[/I][/B]
    >

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,570
    Rep Power
    25

    Default

    For testing you can feed the Scanner class a String. Put all your answers in the String.

  5. #5
    flubbernugget is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

Similar Threads

  1. scanner Class
    By vibaviattigala in forum New To Java
    Replies: 2
    Last Post: 11-30-2010, 07:31 PM
  2. Help with Scanner Class
    By VisionIncision in forum New To Java
    Replies: 7
    Last Post: 11-17-2010, 02:53 PM
  3. Using Scanner class in GUI
    By Indegon in forum New To Java
    Replies: 13
    Last Post: 11-12-2010, 10:50 PM
  4. Using the scanner class
    By danielwestjr in forum New To Java
    Replies: 1
    Last Post: 03-13-2009, 10:49 AM
  5. JDK 5.0 Scanner Class
    By Sircedric88 in forum New To Java
    Replies: 3
    Last Post: 07-27-2007, 06:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •