Because Java uses UTF-8 encoding, and CMD is the default encoding is GBK, so, in the command prompt window compile run Java program, the characters in the program will appear garbled, to solve this problem, there are two ways:
1, the use of chcp command to modify the CMD console character encoding method for Utf-8, the specific method can be Google or Baidu keyword "cmd utf-8", here no longer described.
2, the use of the first way, the display of more Chinese characters, or will appear garbled and display incomplete phenomenon, even compile can not pass. The second method described here is perfectly tested by the author. In the Windows Simplified Chinese system, ANSI encoding stands for GBK, so we save the Java source code file in ANSI encoding to solve the problem of Chinese characters appearing in the cmd Command Prompt window.
CMD console java compilation run, can not display the problem of Chinese characters