title: How can you use vt100 escape codes in java on windows
body: <p>vt100 escape codes are a powerful and popular method for formatting outputs (color, positioning, blinking, underlining etc.) on virtual terminals like xterm or konsole. See <a href="https://en.wikipedia.org/wiki/ANSI_escape_code" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/ANSI_escape_code</a></p>
  
  <p>When you run a java program in xterm, konsole etc. and <code>System.out.print</code> such codes - for example</p>
  
  <pre><code>// print "Hello, World!" in red
  System.out.print("\u001b[31mHello, World!");
  </code></pre>
  
  <p>java passes them to the terminal unaltered, so these terminals interpret the codes then and behave as you expect them to.</p>
  
  <p>Java programs are supposed to be platform independent, though, but when you run such a program from windows command prompt, you will see the codes printed out, like this:</p>
  
  <pre><code>☐[31mHello, World!
  </code></pre>
  
  <p>After searching for a way to solve this problem, I could not find a simple solution or even a discussion about the topic. Most solutions depend on running your program in a different console application or including a java-based custom console into your program.</p>
  
  <p>So - how can you use vt100 formatted text in Windows default command prompt easily?</p>