2

The java.io.Console class requires there to be a Console device (window). How can I debug if I am using this class? I'm using netbeans IDE.

UPDATE: I figured out how to wrap Sysytem.in with a InputStreamReader and then a BufferedReader. This works even without a Console window, so I can use it instead.

If anyone still answers the question of how to debug using the Console class I'd still be interested though!

cchampion
  • 7,607
  • 11
  • 41
  • 51

2 Answers2

1

Another approach is to start the program outside NetBeans with the usual debugging flags and then use the 'Attach Debugger...' item from the Debug menu.

Community
  • 1
  • 1
vkraemer
  • 9,864
  • 2
  • 30
  • 44
0

In NetBeans → open "Output" window, there will be two (or more) tabs: Debugger Console and <YoursProjectName>(debug).

"<YoursProjectName> (debug)" tab is a console window, you can interact with it like with regular console (type anything in that consol tab and read from it in yours app with System.in.read(), System.console().readLine() etc.).

P.S. sorry for necroposting, searched for debugging console apps in NetBeans and found nothing useful (bad "google" skill? =D). Hope my answer will be useful for other newbies.

ankhzet
  • 2,517
  • 1
  • 24
  • 31
  • yeah, that's "ok" but don't you generally have a terminal open for something else, anyhow? plus, you can't just run it with F6, you have to rebuild the entire JAR each time. Because "run" won't rebuild the JAR. unless you don't run the JAR, but directly run the .class, I suppose. – Thufir Aug 30 '13 at 19:56