• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to customize a cmd window called from java?  RSS feed

 
Michael Gensler
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

as the title says, is it possible to customize a cmd window called from java?
I want to set the width and hight, maybe background color and so on.

My current java looks like this:
The bat variable contains the path to the batch file i want to execute.

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you type the command: cmd /? in a command prompt, you'll get an overview of the options that you can pass.

You can change the colors with th /T option. I don't know if you can set the size with an option, but apparently you can change the number of rows and columns with a command:

mode con: cols=AA lines=BB

where AA is the number of columns, BB is the number of lines; see mode /? for more info.
 
Michael Gensler
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!
 
Paul Witten
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Gensler wrote:Hello,

as the title says, is it possible to customize a cmd window called from java?
I want to set the width and hight, maybe background color and so on.

My current java looks like this:
The bat variable contains the path to the batch file i want to execute.


To really customize it you need this http://jansi.fusesource.org/download.html

You can do something like change the foreground color only for error messages, and real time stuff like that. I found it useful for changing foreground colors because I had iterative output that all looked the same on each pass. So I started alternating the fg (text) colors for each pass/output and then you could at least see it scrolling.

The package is quirky though. For instance I can get all the fg and bg colors to work but not the attributes. This is on VISTA though. I mean who knows? But in theory you could set blinking attribute or bold or bright or underline for certain output from your application code.

p
 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, your proposed solutions will work only on a Windows(tm) machine that has access to the 'cmd' shell program. It won't work on other Operating Systems, such as Mac OS-X or Linux or Unix. It may not even work on Windows 8 or Windows 8 RT.

Are you sure you want to do this?
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat Farrell wrote:Are you sure you want to do this?


Particularly since the command line has been obsolete since about 1995, and the vast majority of computer users will never ever see one. The only people who are interested in seeing them are programmers (and other people in similar professions, like network managers). And I expect the majority of those don't really care if their command line windows are customized, either.

Although I may have overlooked the group towards which your application is directed?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!