Solution to Chinese garbled characters when cmd runs java:
1. Set the cmd encoding to utf-8
Open cmd and enter the following command
chcp 65001
This will change the encoding of cmd to UTF-8.
The following are commonly used cmd encodings
2. Specify the encoding method when executing java
In cmd Below, the common commands to run Jar packages are as follows
java -jar project.jar
However, this may cause errors caused by incorrect encoding during java runtime. At this time, we can specify the encoding parameters when running Jar
java -Dfile.encoding=utf-8 -jar project.jar
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of Solution to Chinese garbled characters when running java using cmd. For more information, please follow other related articles on the PHP Chinese website!