learning_record_doc/java/Java CMD运行Jar出现乱码问题.md
2022-02-28 23:07:00 +08:00

28 lines
503 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Java CMD运行Jar出现乱码问题
===========================
### 一、设定CMD的编码为utf-8
##### 打开cmd输入以下命令
```bash
chcp 65001
```
##### cmd常用编码
| 字符编码 | 对应字符 |
| ----------- | -------- |
| GBK默认 | 936 |
| 美国英语 | 437 |
| utf-8 | 65001 |
### 二、规定执行Java时的编码方式
普通运行方式
java -jar project.jar
规定utf-8编码格式运行
java -Dfile.encoding=utf-8 -jar project.jar