Solved

how to clear screen

Posted on 2001-07-16
5
4,029 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

623 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