Results 1 to 6 of 6
  1. #1
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Smile Clear Screen in Console based programs

    Hello guys.... Please help me,,, how can i clear the screen just like "clrscr()" function in C....

    i cannot find a way in java to clear the screen....

    Thanks for the help.. ^_^

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    That's because it doesn't exist, at least not in a straight-forward easy way.

  3. #3
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    for the non-straight-forward way, use exec() in the Runtime Class to call cls or clear. which is not portable btw.
    or you could just use println("\n\n\n\n\n\n\n\n\n\n\n\n...");
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  4. #4
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    hello guys,, thanks for the reply,, i tried the 2nd option, but it says that i need an interface,,

    do i have to import another package for this one?

  5. #5
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    in replay to kirly: Nope.

    actually i just tried it out, and realized my first suggestion don't work. so use the 2nd.
    Java Code:
    public class Test {
      public static void main(String[] args){
        try{
          // DON'T WORK
          Runtime.getRuntime().exec("cls");
        }catch(Exception ex){}
        
        // WORKS
        System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
      }
    }
    Last edited by angryboy; 02-05-2009 at 04:47 AM.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  6. #6
    kirly is offline Member
    Join Date
    Oct 2008
    Posts
    31
    Rep Power
    0

    Default

    hahahaha.. yah ur ryt,, i also tried the Runtime thing, but it didn't work,,,,

    2nd option works but,, it's useless in a way that you can still scroll up for windows...

Similar Threads

  1. i need an example of JSR179 ((Location based Ser)implementation for CDC based device
    By talk_to_vivekmishra in forum CDC and Personal Profile
    Replies: 3
    Last Post: 12-30-2010, 10:07 AM
  2. How to clear JDesktopPane
    By hendrix79 in forum New To Java
    Replies: 12
    Last Post: 12-10-2008, 11:25 PM
  3. I want to do is clear the console
    By paul in forum Advanced Java
    Replies: 7
    Last Post: 08-03-2007, 06:54 PM
  4. Clear screen in java
    By lenny in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 09:43 AM
  5. Replies: 1
    Last Post: 07-23-2007, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •