When someone else's projects and java files are imported into their own eclipse, the Chinese comments of the java files are often garbled, the main reason is that other people's development environment editor encoding format and their own eclipse encoding format is different, such as others with the UTF-8, their own is GBK, in this way, Chinese characters may be garbled after being imported.
The default character encoding of the eclipse workspace is the default encoding of the operating system, and the default encoding of the simplified Chinese operating system (Windows XP, Windows 2000 Simplified Chinese) is gb18030, the project code created in this workspace is gb18030, And the Java file created in the project is also gb18030. We can change the default encoding format of eclipse, and set the encoding format for the entire workspace, the entire project, the entire file type, and a single file. The general Java file encoding format is UTF-8. The following uses changing the default GBK to UTF-8 as an example.
1. Change the encoding format of the entire workspace. In this way, the newly created file will also be in the new encoding format.
Eclipse-> window-> preferences-> General-> workspacetypes-> Other-> UTF-8-> OK
Finished: eclipse-> window-> preferences-> General-> Workspace-> Other-> UTF-8-> OK
2. Set the encoding format for the project scope
Project-> properties-> General-> resource-> Other-> UTF-8-> OK
3. encoding format of a certain type of file
Eclipse-> window-> preferences-> General-> content types-> Find the type of the file to be modified on the right (Java, JSP, etc.)-> In the following default encoding, enter UTF-8 in the input box-> Update-> OK
Chinese version: eclipse-> window-> preferences-> General-> content type-> select the type of the file to be modified on the right-> enter the default encoding below-> Update
4. Set the encoding format for a single file
In package explorer right-click File-> Properties and change the text file encoding format to UTF-8
Note: Back up data before changing the encoding format. In addition, you can use a batch conversion tool to search for many such gadgets on the Internet.
From: http://www.freezq.cn/list/..%5Carticle%5C418.htm