Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-25-2007, 10:19 PM
Member
 
Join Date: Jul 2007
Posts: 26
paul is on a distinguished road
I want to do is clear the console
Hi, All I want to do is clear the console buffer (example "cls in Windows, "clear" in Unix).

I've googled this quite a bit and found nothing useful.
Sun's forums are completely useless, there are about 20 threads asking the same question and the only replies are to put in a loop with a bunch of System.out.println(). There is another "solution" but it's a nasty hack that involves editing system files (and thus makes it difficult to distribute my application!).

I'm just not convinced that there's "no way to do it."
Does ANYONE know how to clear the console??!
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-02-2007, 05:43 PM
Member
 
Join Date: Aug 2007
Posts: 47
henry_78 is on a distinguished road
Hi,
U can try to lunch a dos command from a java program.
try this:

Runtime rt = Runtime.getRuntime();
Process p = rt.exec("cmd /c cls");

Bye
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-03-2007, 05:58 AM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
It doesn't work henry, just tried it
Any other way besides that?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-03-2007, 06:49 AM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
Your out of luck on this one. Clearing the console or moving the cursor around the console is OS specific stuff. And OS specific is not what Java does. In all reality Java makes for a very poor command line application. It is limited to standard in and standard out (and standard err).
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-03-2007, 11:00 AM
Member
 
Join Date: Aug 2007
Posts: 47
henry_78 is on a distinguished road
Hi,
I really didn't undrestand good what u want to do, but i can tell u one thing.
If u want to clear the stdout buffer (the stdout is an output stream) u can do this: System.out.flush();
This command will will force all what u have in the stdout buffer to your console, at this point the buffer will be clear, then try the command that i gave u the other time to clear the screen...i hope it works please let me know, Bye.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-03-2007, 02:38 PM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
I think paul there is trying to make the Java program he made do a clearscreen when a method is call, u know, like in a shell environment where u write cls, put and enter, and then the console would go clean

And Mr. henry there, i tried the code, it wont clear the screen
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 08-03-2007, 04:37 PM
Member
 
Join Date: Aug 2007
Posts: 47
henry_78 is on a distinguished road
I think i know now why it dosent work.
Because i dont have a reference to the java applicationn console.
I can have a refernce to a console i open...
There is a method in the class System ...System.console();
It returns a reference to the virtual machine console (if there is any).
I dont know if it might help u.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 08-03-2007, 07:54 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
Wow I haven't noticed that. I spend most of my time developing for 1.5. The Console class is definitely a step in the right direction for console based apps but, it looks like it still can't clear the screen.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
clear cache Jadellll New To Java 0 03-20-2008 10:27 AM
Please clear my doubt............... vinaytvijayan Advanced Java 0 12-26-2007 07:23 PM
how to clear the data of an object katie AWT / Swing 1 08-06-2007 11:50 PM
Help, someone clear up Interfaces for me mathias New To Java 1 08-06-2007 03:26 AM
Clear screen in java lenny New To Java 1 07-30-2007 10:43 AM


All times are GMT +3. The time now is 02:01 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org