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!

1

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.