143

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.

Ripon Al Wasim
  • 35,466
  • 40
  • 150
  • 172
Katty
  • 1,707
  • 3
  • 13
  • 18

8 Answers8

282

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

boop
  • 6,834
  • 11
  • 47
  • 84
Sajan Chandran
  • 10,929
  • 3
  • 26
  • 37
  • 13
    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](http://stijndewitt.wordpress.com/2010/05/05/unicode-utf-8-in-eclipse-java/) – Stijn de Witt Apr 05 '14 at 14:29
  • 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 ? – Kaushik Lele Jan 16 '15 at 07:06
  • 2
    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. – meustrus Feb 09 '15 at 17:06
  • That is pretty awful... surely the encoding of a project should be dependent on the project, not on the global Eclipse settings? – Nyerguds Sep 06 '16 at 07:48
  • 2
    @Nyerguds: In the Package Explorer, right-click on a project and choose `Properties'. The first entry `Resource' offers exactly what you want. – Ralph Nov 30 '16 at 13:59
  • @sajan : your answer saved my production solr-app deployment..! Thanks a ton..! – Vibhav Singh Rohilla Apr 27 '17 at 05:45
  • Why `Default encoding` of `JS Object Notation File` not works for `*.json`? – softwarevamp Sep 26 '19 at 03:22
45

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

Ripon Al Wasim
  • 35,466
  • 40
  • 150
  • 172
user3249411
  • 451
  • 4
  • 3
12

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

tommybee
  • 2,249
  • 1
  • 18
  • 23
8

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.

Kal
  • 24,289
  • 7
  • 61
  • 63
  • 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. – Ripon Al Wasim Feb 13 '18 at 06:19
0

I tried all settings mentioned in this post to build my project successfully however that didn't work for me. At last I was able to build my project successfully with mvn -DargLine=-Dfile.encoding=UTF-8 clean install command.

JoSSte
  • 2,467
  • 5
  • 28
  • 44
Divu
  • 11
  • 1
0

You can set an explicit Java default character encoding operating system-wide by setting the environment variable JAVA_TOOL_OPTIONS with the value -Dfile.encoding="UTF-8". Next time you start Eclipse, it should adhere to UTF-8 as the default character set.

See https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html

Abdull
  • 24,646
  • 24
  • 120
  • 168
0

If you have problems with JSON files, it turns out in some Eclipse versions there is an embedded JSON Validator. You can turn it off by doing the steps below:

Go to Windows->Validation and Uncheck JSON validation checkboxes

A.Ktns
  • 121
  • 7
-8

You may require to install Language Packs: 3.2

Siva Charan
  • 17,624
  • 9
  • 58
  • 94