Solved

how to clear screen

Posted on 2001-07-16
5
4,011 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
Comment Utility
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
Comment Utility
Hi,

   Try Runtime.exec("cls");

bye
0
 
LVL 6

Expert Comment

by:kotan
Comment Utility
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
Comment Utility
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
Comment Utility
Per recommendation, points refunded and question closed.

Netminder
EE Admin
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

771 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

10 Experts available now in Live!

Get 1:1 Help Now