Completely solve the problem of IDEA outputting Chinese garbled characters

There are a total of 3 methods in this article, and the situation is to output Chinese garbled characters

Problem Description

Unable to output Chinese characters correctly: (Please correctly identify which kind of garbled characters you have!)
insert image description here

Solution

1. Easiest to think of

Under File -> Settings -> File Encodings, set the encoding format to UTF-8, which is the most common. Generally, when the idea is just installed or the project is just imported, the encoding format here has not been modified.
insert image description here
Modify it in one go!

2. If not, it is normal, see here

Modify the idea.exe.vmoption file
Open the bin directory of the idea installation path and find two files, idea.exe.vmoptions and idea64.exe.vmoptions
If you downloaded the 64-bit version, there is only one vmoptions file, which is normal , just modify one line and
add a line at the end of the text.

insert image description here
After saving, you need to restart idea.
Note: It is invalid to modify only in the help->Edit Custom VM Options of the idea

3. If it still doesn’t work, check it out

Go to the project startup configuration to check whether the encoding format of the container is set
Run->Edit Configration
Whether you run the main method directly, the startup method of the SpringBoot project, or tomcat, there is a configuration for
VM options, and this configuration is actively configured as -Dfile.encoding=utf-8, configure and restart the project.

insert image description here
insert image description here
insert image description here

4. If it doesn't work, you may have encountered the same problem as me

I originally downloaded the latest version of JDK, which is the version numbered 18. However, it is said that its built-in is GBK encoding, but my IDEA analysis is UTF-8. The two conflict, so the output is garbled.
Now, it is necessary to completely delete the original version of the JDK and re-download the JDK version 17.
insert image description here
Since both are available, it is really not random to choose which one to choose, depending on which one you need.
Then, just configure JDK in IDEA! ! ! (Environment variables and font size modification will not be mentioned)
insert image description here
At this time, the problem is finally solved.
This problem of garbled characters has really troubled me for a long time. It is strange that none of the methods found on the Internet are applicable. In the end, it is still a question of the version, and I have learned a lot.

Guess you like

Origin blog.csdn.net/m0_51499597/article/details/124664471