Home  >  Article  >  Java  >  Garbled characters appear in the java console

Garbled characters appear in the java console

王林
王林Original
2019-11-16 14:14:244162browse

Garbled characters appear in the java console

The encoding of java resources are all utf8, and they are compiled using utf8. However, when outputting from the console, Chinese characters will still appear garbled.

eclipse console

The encoding of the eclipse console defaults to the encoding of the operating system, such as GBK. At this time, utf8-encoded Chinese characters cannot be displayed correctly, and the encoding of the console needs to be specified as utf8.

Steps:
Menu: Run Configuration | Console Encoding of Common tab on the right select UTF-8 encoding

Garbled characters appear in the java console

cmd control The encoding of the cmd console defaults to the encoding of the operating system, such as GBK. Same as above, there will be problems when displaying Chinese characters. It can be set like this:

1. Open cmd.exe

2. Execute chcp 65001 to change the code page. 65001 is UTF-8 and 936 is Chinese characters.

3. Specify the encoding java -Dfile.encoding=UTF-8 xxx

when executing the java command. Recommended tutorial:

Java tutorial

The above is the detailed content of Garbled characters appear in the java console. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn