1

The application creates and displays various Swing widgets, and also writes debugging messages to System.out. If I start it as java -jar ...jar then I see it, but if I click on jar file in GUI I don't see the console. How to make it show console to user explicitly, e.g. on reaction to "View -> Debug output" menu item?

Expecting something that will pop up cmd.exe window on Windows, xterm/... on Linux, but it may be Swing window as well. How to do it the easily?

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
Vi.
  • 37,014
  • 18
  • 93
  • 148

3 Answers3

3

First don't use System.out to log, use some Logging framework to write logs in some file and to display the debugging logs open a new JDialog with JTextArea or JTextPane in it. Read the log file content and display that in the textArea. This way it will also solve platform dependency.

Community
  • 1
  • 1
Harry Joy
  • 58,650
  • 30
  • 162
  • 207
1

I think that you looking for CTRL + SHIFT + F1 works if is GUI visible here you can see output to the console, with Tree hierarchy of JComponents

mKorbel
  • 109,525
  • 20
  • 134
  • 319
0

AFAIK on Windows the console would be displayed on the first console output (i.e. System.out.printXXX), while on Linux it must be executed from console itself to do so. I'd rather create a separate window with a JTextArea (or something similar) to display the debug output. Normal users won't care about / need it, right?

LeleDumbo
  • 9,192
  • 4
  • 24
  • 38
  • No, in Windows it does not pop up the console on output to it. Probably will use more proper logger and JTextWhatever log window. – Vi. Jan 03 '12 at 10:22
  • Hmm... it does on my XP, if the interpreter used is java instead of javaw. – LeleDumbo Jan 03 '12 at 14:23