File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why do i get an exception?

 
Damien Howard
Ranch Hand
Posts: 456
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I am running this on a windows machine. It goes into the windows clause and it assigns cls to my var, but I get an IOException and my cmd window is not cleared. Does anyone know why?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably because here's no "cls.exe"; it's a command built into the shell. You'd have to exec something like "cmd /E cls" -- i.e., run the shell, and tell it to execute the cls command.

But -- and this is a big "but" -- that shell wouldn't be connected to a terminal window; it takes input from the Java process. So the cls command would have no effect!

There are two ways to clear a terminal window from a Java program: first, send a (platform dependent) escape sequence to the terminal to clear it (Google for "ANSI escape codes" to learn more) or just print a bunch of blank lines to make the contents of the screen scroll away!
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic