how to clear dos console from java

  • Thread starter Johnson Scaria John
  • Start date
J

Johnson Scaria John

How to clear DOS prompt from java ?. (Function instead of clscr in c)

//String ANSI_CLS = "\u001b[2J";
System.out.print((char)27 + "[2J");
Runtime.getRuntime().exe("cmd.exe","/c","cls");

are not working in windowsNT
 
D

Donkey Hot

How to clear DOS prompt from java ?. (Function instead of clscr in c)

//String ANSI_CLS = "\u001b[2J";
System.out.print((char)27 + "[2J");
Runtime.getRuntime().exe("cmd.exe","/c","cls");

are not working in windowsNT

To enable Esc-sequences:

For Windows NT, Windows 2000 and Windows XP:
Create or edit the CONFIG.NT file. (Usually found in the WINNT\SYSTEM32
directory.)

Add the following line to the file:
DEVICE=%systemroot%\system32\ANSI.SYS

Save CONFIG.NT with the new line.

Check that a copy of ANSI.SYS exists in the specified path location.
Restart the computer to complete the change.

http://academic.evergreen.edu/projects/biophysics/technotes/program/ansi_es
c.htm
 
J

Johnson Scaria John

Very very thanks for looking this.

I just do that what you said.but its show [2j.Can you say how this
happens and way to solve this problem.


How to clear DOS prompt from java ?. (Function instead of clscr in c)
//String ANSI_CLS = "\u001b[2J";
System.out.print((char)27 + "[2J");
Runtime.getRuntime().exe("cmd.exe","/c","cls");
are not working in windowsNT

To enable Esc-sequences:

For Windows NT, Windows 2000 and Windows XP:
Create or edit the CONFIG.NT file. (Usually found in the WINNT\SYSTEM32
directory.)

Add the following line to the file:
DEVICE=%systemroot%\system32\ANSI.SYS

Save CONFIG.NT with the new line.

Check that a copy of ANSI.SYS exists in the specified path location.
Restart the computer to complete the change.

http://academic.evergreen.edu/projects/biophysics/technotes/program/a...
c.htm
 
D

Donkey Hot

Very very thanks for looking this.

I just do that what you said.but its show [2j.Can you say how this
happens and way to solve this problem.

No can do. Apparently java uses the console in a way that ansi.sys gets
ignored.



(e-mail address removed):
How to clear DOS prompt from java ?. (Function instead of clscr in
c)
//String ANSI_CLS = "\u001b[2J";
System.out.print((char)27 + "[2J");
Runtime.getRuntime().exe("cmd.exe","/c","cls");
are not working in windowsNT

To enable Esc-sequences:

For Windows NT, Windows 2000 and Windows XP:
Create or edit the CONFIG.NT file. (Usually found in the
WINNT\SYSTEM32 directory.)

Add the following line to the file:
DEVICE=%systemroot%\system32\ANSI.SYS

Save CONFIG.NT with the new line.

Check that a copy of ANSI.SYS exists in the specified path location.
Restart the computer to complete the change.

http://academic.evergreen.edu/projects/biophysics/technotes/program/a.
.. c.htm
 
J

Johnson Scaria John

Thanks
I am using console class of java 1.6. In my system has a file ansi.sys
at winnt/system32.
I just write command "DEVICE=%systemroot%\system32\ANSI.SYS" in
config.nt file but its not working > you have any suggestion.
?
Johnson Scaria John said:
Very very thanks for looking this.
I just do that what you said.but its show [2j.Can you say how this
happens and way to solve this problem.

No can do. Apparently java uses the console in a way that ansi.sys gets
ignored.


(e-mail address removed):
How to clear DOS prompt from java ?. (Function instead of clscr in
c)
//String ANSI_CLS = "\u001b[2J";
System.out.print((char)27 + "[2J");
Runtime.getRuntime().exe("cmd.exe","/c","cls");
are not working in windowsNT
To enable Esc-sequences:
For Windows NT, Windows 2000 and Windows XP:
Create or edit the CONFIG.NT file. (Usually found in the
WINNT\SYSTEM32 directory.)
Add the following line to the file:
DEVICE=%systemroot%\system32\ANSI.SYS
Save CONFIG.NT with the new line.
Check that a copy of ANSI.SYS exists in the specified path location.
Restart the computer to complete the change.
http://academic.evergreen.edu/projects/biophysics/technotes/program/a.
.. c.htm
 
R

RedGrittyBrick

Sue: Because it conflicts with normal English reading order.
Joe: Why do you say that?
Sue: Top-Posting!
Joe: What is one of the most annoying things on usenet?


Johnson Scaria John top-posted:
Thanks I am using console class of java 1.6. In my system has a file
ansi.sys at winnt/system32. I just write command
"DEVICE=%systemroot%\system32\ANSI.SYS" in config.nt file but its not
working > you have any suggestion. ?


See http://en.wikipedia.org/wiki/ANSI_escape_code#Windows_and_DOS
which I think explains this reasonably well:

"ANSI output from 16-bit legacy programs executing under the NTVDM will
be interpreted"

I guess the JVM isn't 16-bit - though perhaps MS would be happy to label
it legacy :)

I think this leaves the following choices:

* Use JNI to use the Windows Console API.
* Output sufficient newlines.
* Write a thin Swing wrapper using e.g. a JTextArea.
* etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top