How to support UTF-8 encoding in Eclipse

250,891

Solution 1

Try this

  • 1) Window > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types.

  • 2) Window > Preferences > General > Workspace, set Text file encoding to Other : UTF-8

Solution 2

Open Eclipse and do the following steps:

  1. Window -> Preferences -> Expand General and click Workspace, text file encoding (near bottom) has an encoding chooser.
  2. Select "Other" radio button -> Select UTF-8 from the drop down
  3. Click Apply and OK button OR click simply OK button

enter image description here

Solution 3

You can set a default encoding-set whenever you run eclipse.exe.

  1. Open eclipse.ini in your eclipse home directory Or STS.ini in case of STS(Spring Tool Suite)
  2. put the line below at the end of the file

-Dfile.encoding=UTF-8

Solution 4

Just right click the Project -- Properties and select Resource on the left side menu.

You can now change the Text-file encoding to whatever you wish.

Share:
250,891
Katty
Author by

Katty

Updated on March 13, 2021

Comments

  • Katty
    Katty about 3 years

    How can I add UTF-8 support in eclipse? I want to add for example Russian language but eclipse won't support it. What should I do? Please guide me.

    • soulcheck
      soulcheck about 12 years
      do you want to use translated eclipse or simply change the file encoding?
    • Nyerguds
      Nyerguds over 7 years
      Is this about code, or resources? UTF-8 resource support takes a bit more work.
    • Ripon Al Wasim
      Ripon Al Wasim almost 7 years
      I need Chinese language support in eclipse for Selenium WebDriver tests.
  • Stijn de Witt
    Stijn de Witt about 10 years
    I wrote a blog post about this very topic which illustrates this in great detail (with screenshots etc): Unicode/UTF-8 in your Eclipse Java projects
  • Kaushik Lele
    Kaushik Lele over 9 years
    I am not able to accept UTF-8 characters as input from console. Scanner sc=new Scanner(System.in); sc.nextLine(); here if I give non-English characters it gets something garbage. What changes needed in setting or in program ?
  • meustrus
    meustrus about 9 years
    Kaushik Lele: Your question does not relate the the question asked here. I invite you to search for your solution in other questions, or if none exist, ask your own question.
  • Nyerguds
    Nyerguds over 7 years
    That is pretty awful... surely the encoding of a project should be dependent on the project, not on the global Eclipse settings?
  • Ralph
    Ralph over 7 years
    @Nyerguds: In the Package Explorer, right-click on a project and choose Properties'. The first entry Resource' offers exactly what you want.
  • Vibhav Singh Rohilla
    Vibhav Singh Rohilla almost 7 years
    @sajan : your answer saved my production solr-app deployment..! Thanks a ton..!
  • Ripon Al Wasim
    Ripon Al Wasim about 6 years
    I followed the steps you mentioned above and changed into UTF-8 for console printing for Chinese an Russian languages. But unfortunately it didn't work.
  • softwarevamp
    softwarevamp over 4 years
    Why Default encoding of JS Object Notation File not works for *.json?