28 lines
503 B
Markdown
28 lines
503 B
Markdown
|
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
|