Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to clear screen (clrscr) in java?

 
Rajesh Tatooskar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I clear the screen (console) in java?
Something similar to clrscr() that is available in C?
Thanks,
Rajesh
 
Amit Gulhane
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IF you are using Linux then try
print "\033[2J"
OR
print "\033[0;0f"
OR
char esc = 27;
String clear = esc + "[2J";
System.out.print(clear);
[ September 03, 2003: Message edited by: Amit Gulhane ]
 
Ray Muntz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what if you have a diff OS. I for example have Win ME(Shoot me now!)
how would i go about this.
Thanks for any help on the subject.

P.s. does anyone know of a good site on Using the 'java.io' package? thanks
[ October 19, 2003: Message edited by: Ray Muntz ]
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ray Muntz:
But what if you have a diff OS. I for example have Win ME(Shoot me now!)
how would i go about this.
Thanks for any help on the subject.

System.out.println("\n\n\n\n\n\n\. . .

P.s. does anyone know of a good site on Using the 'java.io' package? thanks
[ October 19, 2003: Message edited by: Ray Muntz ]


The Java Tutorial
 
Ray Muntz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the IO tutorial,
i was hoping there was another solution, but that seems to be all i can find as well. thanks anyway. i guess im just doomed to have no CLS... oh well.
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ray Muntz:

i was hoping there was another solution, but that seems to be all i can find as well. thanks anyway. i guess im just doomed to have no CLS... oh well.

There is another solution. I used JNI to use the Win32 console control routines. Of course, I've only tested it on Win2k. It should work on Win95-98. If you are really desperate, I will e-mail it to you.
 
Vinod Chandana
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ray,
U can try using Runtime and Process and then making a call to cls or clear based on ur os and then executing it. I havent tried it. I think this will work.
- Vinod.
Originally posted by Ray Muntz:
Thanks for the IO tutorial,
i was hoping there was another solution, but that seems to be all i can find as well. thanks anyway. i guess im just doomed to have no CLS... oh well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic