Garbled characters in the Windows command line?
By hajma on Jun 15, 2009
Do you use OpenDS, Glassfish, Directory Server Enterprise Edition or other Java applications on german,
french or spanish Microsoft Windows and see the accentuated
characters like ùûüÿàâäçéèêëïîñóôöœßÙÛÜŸÄÀÂÇÉÈÊËÏÎŒÑÖÓÔ garbled in the command line interface? Here's why and how to
Unlike UNIX and UNIX-like systems, Microsoft Windows lacks the benefits of utf-8 encoding. Instead a mess of ANSI and OEM "codepages" is used. A bug in the JDK 5 System.out/.in/.err classes causes the wrong codepage to be selected when the application is attached to a DOS console window. The bug was found too late, so it became a feature.
The java.io.Console class in JDK 6 detects the codepages correctly and should be therefore preferred. However we still support JDK 5, so the old classes are used and you still meet broken french/german/spanish/... CLI.
Fortunately there's an easy workaround:
Right-click on the title bar of the cmd.exe window and choose 'Properties'. In the 'Font' tab switch the font to Lucida Console and click OK. Then in the cmd.exe window issue the below command: