• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 27450
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Hug your destiny! And hug this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic