Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to clear screen

Posted on 2001-07-16
5
Medium Priority
?
4,034 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

Independent Software Vendors: 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

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 …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

972 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