147

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.

3
  • 1
    do you want to use translated eclipse or simply change the file encoding? Commented Feb 7, 2012 at 17:39
  • Is this about code, or resources? UTF-8 resource support takes a bit more work. Commented Sep 6, 2016 at 7:55
  • I need Chinese language support in eclipse for Selenium WebDriver tests. Commented Jun 15, 2017 at 5:24

12 Answers 12

293

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

Sign up to request clarification or add additional context in comments.

6 Comments

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
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: 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.
That is pretty awful... surely the encoding of a project should be dependent on the project, not on the global Eclipse settings?
@Nyerguds: In the Package Explorer, right-click on a project and choose Properties'. The first entry Resource' offers exactly what you want.
|
49

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

Comments

13

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

2 Comments

don't advise, cos in my case, when i tried it didn't work, and moreover eclipse started act weird.
@Farkhod Abdukodirov I think file encoding is not an UTF-8 when to set up your eclipse project so it might be a problem though...
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.

1 Comment

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.
8

Right click on main source -> Run As -> Run Configurations -> (x)= Arguments -> VM arguments -> add:

-Dsun.stdout.encoding=UTF-8 

1 Comment

it worked for me , thanks. In fact, until I reach this answer comment, I tried all, but unfortunately they didn't work, maybe it also depends on OS system environment.
4

September 24, 2022 Update:
JDK 19 (released on September 20, 2022) has System property

stdout.encoding 

which can be set to UTF-8, i.e. add the following option to the java command:

-Dstdout.encoding=UTF-8 

Comments

1

If you have Windows 11, and none of the previous answers worked, you could need to change your Region settings. Follow these steps:

Quick instructions:

Windows search > Control Panel > Region > Administrative tab > Change system locale... > check Beta: Use Unicode UTF-8 for worldwide language support > OK > Restart now

Full instructions:

  1. Go to the Windows search: Press the Win key, or just click on the Search button. Another way you can go is by pressing the Win + s shortcut.
  2. Type Control Panel and press enter key to open it, or simply click on the first search result.
  3. Click on the View by dropdown menu in the upper right corner and select Category (if the view is not set by Category).
  4. Go to Clock and Region.
  5. Click on Region.
  6. Go to the Administrative tab.
  7. In Language for non-Unicode programs, click on Change system locale... button.
  8. Check the Beta: Use Unicode UTF-8 for worldwide language support option.
  9. Click OK.
  10. Click Restart now.

You should be able to see the characters properly in Eclipse.

Comments

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

Comments

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

Comments

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.

Comments

0

In my case, just right click on the file you want to change the encoding -> Properties and select Resource on the left side menu. In Text file encoding click other and change to UTF-8. Hope to help you.

change encoding of file

Comments

-8

You may require to install Language Packs: 3.2

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.