Home >Java >JavaBase >Solution to Chinese garbled characters when running java using cmd

Solution to Chinese garbled characters when running java using cmd

尚
Original
2019-12-26 15:32:0516768browse

Solution to Chinese garbled characters when running java using cmd

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

Solution to Chinese garbled characters when running java using cmd

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!

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