console : Java Glossary

console

A window where you can view the System.out.println and other debugging data from a Java application or Applet. Sometimes it will be covered over by the Applet or Java Web Start app. Sometimes you have to enable it.

In Java 1.5, if an Applet fails, it will sometimes display a broken icon. Right click on it and that will give you the option to look at the Java console to learn why. The stack trace might mean nothing to you, but it will to those who wrote the program. Copy the entire contents to help in diagnosing the problem.

Engaging the Java Console in Your Browser Redirection
java.exe vs javaw.exe Console Window Size
Writing to the Console Reading From The Console
Import Static Shortcut Learning More
Merging System.out and System.err Links

Engaging the Java Console in Your Browser

If you are in a browser you have to enable to console before you can see it. Avant and Chrome do not support Java, or more precisely, their support does not work. Safari does support the Java console.

SeaMonkey logo Sea Monkey Engaging the Console

Last revised/verified: 2006-03-19
In SeaMonkey, you enable the console with:
  1. Click Edit.
  2. Click Preferences.
  3. Click Advanced.
  4. Click “Enable Java”.
  5. Click OK.
You also have to enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.
  9. Click OK.
  10. Click File.
  11. Click Close.
Finally, to make the console visible:
  1. Click Tools.
  2. Click “Web Development”.
  3. Click “Java console”.

Opera logo Opera Engaging the Console

Last revised/verified: 2006-02-07
In Opera you can enable the console with:
  1. Click Tools.
  2. Click Advanced.
  3. Click “Java Console”.
You also have to enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista/W7-32/W7-64, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.
  9. Click OK.
  10. Click File.
  11. Click Close.
Finally, to make the console visible:
  1. Click Tools.
  2. Click Advanced.
  3. Click “Java console”.

Internet Explorer logo Internet Explorer Engaging the Console

Last revised/verified: 2006-02-07
In Internet Explorer, you enable the console with:
  1. Click Tools.
  2. Click “Internet Options”.
  3. Click Advanced.
  4. Click “Java Sun”.
  5. Select Use Java (pick latest). Do not use the MS JVM (Java Virtual Machine).
In Windows, you also have to enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.
  9. Click OK.
  10. Click File.
  11. Click Close.
  12. Restart your browser.
In Mac OS Leopard, you also have to enable the console on the Java Preferences Application.
  1. Applications
  2. Utilities
  3. Java Preferences Application.
  4. Click Advanced.
  5. Click “Show Console”.
  6. Restart your browser.
Finally, to make the console visible:
  1. Click Tools.
  2. Click “Sun Java console”.

Java logo Java.exe Engaging the Console

Last revised/verified: 2006-02-07
In java.exe the console is enabled by default; you turn it off by using javaw.exe instead. You also have to enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.

Java Web Start logo  javaws.exe Engaging the Console

Last revised/verified: 2006-02-07
In jawaws.exe (Java Web Start), you must:
  1. start javaws.exe
  2. Click edit.
  3. Click preferences.
  4. Click advanced.
  5. Click “+ Java console”.
  6. Click “Show Console”.
  7. Click OK.

safari safari Engaging the Console

Last revised/verified: 2011-10-26
In Safari, you enable/disable to Java console with the Java Control Panel. Here is how you enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.
  9. Click OK.
  10. Click File.
  11. Click Close.

firefox firefox Engaging the Console

Last revised/verified: 2011-10-26
In Firefox 7, you enable/disable to Java console with the Java Control Panel. Currently the the add-in needed to make the console work is incompatible with the latest version of Firefox. Firefox add-ins require constant modification to continue working. In older versions you could enable it with:
  1. Click Tools.
  2. Click Options.
  3. Click Content.
  4. click “Enable Java”.
  5. click OK.
You also have to enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.
  9. Click OK.
  10. Click File.
  11. Click Close.

Mozilla logo Mozilla Engaging the Console

Last revised/verified: 2006-02-07
In Mozilla, you enable the console with:
  1. Click Edit.
  2. Click Preferences.
  3. Click Advanced.
  4. Click “Enable Java”.
  5. Click OK.
You also have to enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.
  9. Click OK.
  10. Click File.
  11. Click Close.
Finally, to make the console visible:
  1. Click Tools.
  2. Click “Web Development”.
  3. Click “Java console”.

Netscape logo Netscape Engaging the Console

Last revised/verified: 2008-01-07
In Netscape, you enable the console with:
  1. Click Netscape ! shield icon 
  2. Click Advanced.
  3. Click “Enable Java”.
  4. Click Done.
You also have to enable the console on the Java Control Panel.
  1. Click “task bar Start”.
  2. Click Settings.
  3. Click “Control Panel”.
  4. On Vista, click Programs.
  5. Double click Java.
  6. Click Advanced.
  7. Click “+ Java console”.
  8. Click “Show Console”.
  9. Click OK.
  10. Click File.
  11. Click Close.

java.exe vs javaw.exe

You can hide the console by using javaw.exe (java without) instead of using java.exe.

One of the most useful associations to set up is to make *.jar files executable with java.exe. Then you can just type the name of the jar on the command line to start it executing. If you use javaw.exe rather than java.exe you won’t see the console output. Watch out, Java installers often associate *.jar files with javaw.exe instead of java.exe, overriding your setting.

Writing to the Console

You normally do I/O to the console with System.out.println. For details of how, see the File I/O Amanuensis. Mainly the console is used for debugging or crude programs like HelloWorld. There are no cursor positioning or colour commands. In theory you could insert your own ANSI (American National Standards Institute) control sequences, but Windows/NT just ignores them, even if you install ANSI.SYS. If your console supports ANSI sequences you could use:
System.out.print( "\033[H\033[2J" );
You can effectively clear the console with a println loop of about 80 lines. This won’t clear a log file of course. You can also write to the less-redirectable error log with System.err.println.

Some consoles don’t display System.out data, just System.err. It is thus probably best to get in the habit of using System.err.println for debugging or error message output.

Import Static Shortcut

TheJava version 1.5 or later import static feature can be used to abbreviate code to write to the console.

Merging System.err and System. out

To merge System.err and System. out you could use setErr and setOut to point them to the same PrintStream, e.g. System.setErr( System. out );

Redirection

You can redirect any output to the console with the usual DOS (Disk Operating System) piping commands, namely > and |. You can also internally redirect System.out to a file with System.setOut, and System.err to a file with System.setErr. You can also, of course, write directly to files using a PrintWriter. If you use 4DOS or tcc/TakeCommand you can redirect stdout with 1> and stderr with 2>. You can also use the tee utility to get the output both in a file and on the console. See tcc/TakeCommand for details. You can find similar features in other script languages.

Console Window Size

In NT or tcc you can expand the size of the DOS window and make it scrollable. Right click the DOS box shortcut ⇒ properties ⇒ layout ⇒ screen buffer size ⇒ height That way you can scroll back and see stuff that has rolled off the screen.

Reading From the Console

When you use the console for input, you use Ctrl-Z to signal EOF (End Of File) in Windows and Ctrl-D in most Unices.

You can’t read a single character from the console, the way you can with getC in C. The operating system delivers I/O a line at a time. The program can’t read the characters in a line until the user hits Enter. This allows the user to correct mistakes with BS before Java sees them.

How do you get around this? AWT (Advanced Windowing Toolkit) keystroke events are registered immediately. You can thus accept data in a component. You need to fake a console with a TextArea or similar component.

Peter van der Linden created a set of simple console routines for reading character data in various formats called EasyIn. I seem to recall him also writing a keystroke by keystroke class, but I can find no record of it.

Learn By Experimenting

When you write on the console with Java strange things happen to the Unicode characters. They get modified in various ways so what you see on the screen can be quite astonishing. Factors that affect what you see include:

Rather than trying to explain what happens, I suggest you experiment with the following program that will send a selection of common Unicode characters to the console. Have a look at the results to understand what to expect with your own progams.

Learning More

Oracle’s Javadoc on System.err : available:
Oracle’s Javadoc on System.out : available:
Oracle’s Javadoc on System.in : available:
Oracle’s Javadoc on System.setErr : available:
Oracle’s Javadoc on System.setOut : available:
Oracle’s Javadoc on System.setIn : available:

CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/console.html J:\mindprod\jgloss\console.html
logofeedback Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email If you want your message kept confidential, not considered for posting, please explicitly specify that.
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.179.213]
You are visitor number 93,666.