How to change command prompt (console) window title from command line Java app?

后端 未结 4 1121
南旧
南旧 2020-12-17 22:24

How to change and update the title of the command prompt window from the java command line application? Every time I run my application, the command prompt window title show

4条回答
  •  情歌与酒
    2020-12-17 22:43

    This depends on your terminal emulator, but essentially it's just printing out control sequences to the console.

    Now I'm not clear on what control sequences CMD.EXE responds to (I haven't one available to try this on) but I hear there's a command called TITLE which sets the title of the window. I tried piping TITLE's output to a file, but apparently, it doesn't actually set the title by outputting control characters. The START command can take a parameter which is title of the window followed by the command to run in the window. So something like

    cmd TITLE "lovely Application that is in a command window." && "java" MyApp
    REM or
    start "lovely Application that is java based." java MyApp
    

    Personally I would just bundle the whole thing with a shortcut where you can edit the properties such as the current directory, the command, it's parameters, and the window size, style and title (if I remember rightly). Give it a nice icon and people will use it.

提交回复
热议问题