Home > Java > JavaBase > body text

Solution to Chinese garbled characters when running java using cmd

Release: 2019-12-26 15:32:05
Original
16738 people have browsed it

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
Copy after login

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
Copy after login

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
Copy after login

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!

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