1. How do you clear the screen in a console java app?

2. How do you input text in the console area? Is it something with System.in?

...There may be more later :-P

15 Years
Discussion Span
Last Post by freesoft_2000
  1. I've never done this so I'm not too clear on this. I think you have to set some kind of system property and then you can get properties of the console, and use escape sequences to clear console.

    public class Hello
                 public static void main(String[] args)

lol this question was posted like half a year ago, but ohh welll.

Edited by pyTony: fixed formating


Console applications should never clear the screen. They should not even assume they have sole control over the screen below the point they're started from (for example, another application running in the background may well interrupt them to write something to the output itself, this could be the JVM writing some error message for example).


Hi everyone,

The simple answer is you can't but you can do this, it's a rather stupid way but it works

void public clear () 
int i = 0;



It does the trick for me

I hope this helped you

By the way do you know how to print the contents of a JTextPane??

Yours Sincerely

Richard West

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.