This post shows how to view the opened file encoding in the Eclipse source editor. And also How to change the default encoding to another character encoding. How to get default encoding?

How to view the encode of an opened project or file?

You can check the encode for a file folder or project resource.

  • Right-click on a folder or file resource on the left side of Package Explorer
  • Select Properties or use the shortcut key Alt + Enter
  • You can see Text File Encoding with the default encoding of a given resource.
  • It shows UTF-8 as the default encoding.

Eclipse show default encoding

You can change the resource encoding to another encoding and save the changes. This change applies to only selected resources.

How to change default text file encoding in Eclipse?

In this, changing default encoding applies globally, which means all projects opened with Eclipse.

  • Open Windows Menu > Preferences It opens Preferences Window

  • In the General tab> Select Workspace

  • It Contains a Text File Encoding panel section and contains the following radio options

    • Default(cp1252)
    • Other dropdown contains ISO-8859-1,US-ASCII,UTF-16,UTF-16BE,UTF-16LE,UTF-8 values.
  • Select one of the options from the dropdown

  • Click on Apply and Close.

How to change encoding based on file extension types in Eclipse?

Following are steps

  • Open Windows Menu > Preferences It opens Preferences Window
  • In General tab> Select Content Types
  • Select the file types in the Content Types section
  • Selected Java Source File and it shows File associations as *.java, you can still add a new file extension pattern.
  • Change the Default encoding textbox value to UTF-16
  • Click on the Update button
  • Finally, Click on Apply and Close

You can check the options as per the below screenshot.

Eclipse Change encoding for file extensions