Solved

how to clear screen

Posted on 2001-07-16
5
4,014 Views
Last Modified: 2010-02-09
Dear friends,

  Can u tell me, how to clear screen in java console base programming. (In c or cpp there is clrscr(), like wise something in java)

------------------------------------------------

 I am using Windows 98 operating system . I try with  Runtime.exec("command /c cls") like--

class test
{
  test()
  {
    Runtime.exec("command /c cls");
  }
  public static void main(String []aa)
  {
    test t = new test();
    System.out.println("Hello");
  }
}

 but error is coming. error is -

  Can't make static reference to method java.lang.Process exec(java.lang.String) in class java.lang.Runtime.
 

  if u have any solution then pl tell me.


-suraj deo
0
Comment
Question by:surajdeo
5 Comments
 
LVL 1

Expert Comment

by:googlyralph
ID: 6285655
Due to the platform independance of Java im not usre you can. In the past i use a method that does println('') 's in a forloop, the controll for the loop being an argument to the method.

eg:

protected void clear(int lines){
   for(int x = 0; x < lines; x++){
      System.out.println('');
   }
}

GR.
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 6285676
Hi,

   Try Runtime.exec("cls");

bye
0
 
LVL 6

Expert Comment

by:kotan
ID: 6292334
for NT
     Runtime.exec("cmd /c cls");

for Win95/98
     Runtime.exec("command /c cls");

for Unix
     Runtime.exec("clear");
0
 
LVL 5

Expert Comment

by:vemul
ID: 7669778
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- To be PAQ'ed and points refunded
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7714899
Per recommendation, points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now