We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,621 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion
hello all how can i clear the DOS screen through java program i hava search so many web site but i can't found the proper ans. thanx in advance [:)]

Use Jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.

Steps:

1. Download the jansi-1.6.jar

2. Code to test jansi api.

import org.fusesource.jansi.*;

public class Test
{
  public static void main(String []args)
  {
       AnsiConsole.systemInstall();
       Ansi ansi=Ansi.ansi();
        
       System.out.println(ansi.eraseScreen());

       AnsiConsole.out.println(ansi.bg(Ansi.Color.RED) + "Hello");
 }
}

3. Compile and run

>javac -cp .;jansi-1.6.jar Test.java

>java -cp .;jansi-1.6.jar Test

__avd
Posting Genius (adatapost)
Moderator
8,736 posts since Oct 2008
Reputation Points: 2,141
Solved Threads: 1,262
Skill Endorsements: 50

System.out.print("\f");

works for me
there are diffrent commands recognigzed for different versions

shre
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

shre: this thread hasn't been answred/ followed for almost a year, I think the OP (who asked the question over two years ago) by now has his/her answer or doesn't really care anymore.

stultuske
Industrious Poster
4,366 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 23

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0597 seconds using 2.78MB