• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to clear screen (clrscr) in java?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic