In Ubuntu, how does one fix the garbled content in the Java file of eclipse in Windows?

Source: Internet
Author: User
Today, I opened my previous project and wanted to see the code I wrote. After opening the project, I found that the comments of the previous Java source file were garbled. So I searched Baidu and got the conclusion: the cause of the problem: Because the default encoding in Windows is GBK, Ubuntu is the UTF-8, so in Windows under the annotation, Ubuntu becomes garbled. There are two solutions: 1. Change the Ubuntu system encoding to GBK, which is consistent with the Windows encoding, but I cannot use this method.

Today, I opened my previous project and wanted to see the code I wrote. After opening the project, I found that the comments of the previous Java source file were garbled. So I searched Baidu and got the conclusion: the cause of the problem: Because the default encoding in Windows is GBK, Ubuntu is the UTF-8, so in Windows under the annotation, Ubuntu becomes garbled.

There are two solutions:

1. Change the Ubuntu system encoding to GBK, which is the same as the Windows encoding, but I failed to use this method.
Execute Command
Sudo vi/etc/environment
Change the file content:
1. PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
2. LANGUAGE = "zh_CN: zh: en_US: en"
3. # system code UTF-8
4. # LANG = "zh_CN.UTF-8"
5. # change the system default encoding to GBK.
6. GST_ID3_TAG_ENCODING = GBK
7. LANG = zh_CN.GBK
8. LC_CTYLE = zh_CN.GBK

Restart Ubuntu. But I have not succeeded in the experiment. Why? If anyone knows, please leave a message on the blog and let me know.

2. method 2
1) eclipse-> window-> preferences-> General-> Content Types
2) Find the type of the file to be modified. There is a Default encoding below, and enter GBK in the input box.
3) Click Update.
4) Click OK.
5) Restart eclipse

Open the source file and garbled characters disappear.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.