Home > Java > JavaBase > body text

Introduction to solutions to garbled characters in the Java console

Release: 2019-12-10 17:10:01
Original
2287 people have browsed it

Introduction to solutions to garbled characters 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. (Recommended: java video tutorial)

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

Introduction to solutions to garbled characters in the Java console

cmd console

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. You can set it like this:

Open cmd.exe

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

Specify the encoding java -Dfile.encoding=UTF-8 when executing the java command xxx

For more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of Introduction to solutions to garbled characters in the Java console. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!