954,193 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Some Simple Console App Questons (Java)

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

Tekmaven
Software Architect
Moderator
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
 

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.

2) public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello");
}
}

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

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

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).

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

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;

for(i=0;i<300;i++)
{
System.out.println("\n");
}

}


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

freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You