Eclipse: Project 'Project_Name' Has No Explicit Encoding Set

Eclipse: Project 'Project_Name' Has No Explicit Encoding Set

I downgraded from Windows 11 to Windows 10 today and had to reinstall the Eclipse-IDE.
After successfully importing my workspaces and fixing the projects, a warning appeared for every project saying "Project XXX has no explicit encoding set". I've already searched for a solution and only got some fixes for VSCode.

I had Eclipse 2021-6 and installed Eclipse 2022-6

3

5 Answers

Yes, the warning for projects with no explicit default encoding is a new thing in Eclipse 2022-06 (4.24).

To set an explicit default encoding do one of the following:

  • In the Problems view, select the warning, hit Ctrl+1 and apply the provided Quick Fix (sets the project encoding explicitly to the workspace encoding)
  • Change the project manually in Project > Properties: Resource

See also my video showing and explaining this.

When using a build system like Maven or Gradle, set the encoding as follows instead:

Maven

  1. In pom.xml set the property project.build.sourceEncoding to UTF-8:
    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
  2. Right-click the project folder and choose Maven > Update Project...

Gradle

  1. In build.gradle set compileJava.options.encoding to UTF-8:
    compileJava.options.encoding = 'UTF-8'
  2. Right-click the project folder and choose Gradle > Refresh Gradel Project
  3. As long as Eclipse Buildship issue #344 is not fixed, change the encoding manually as described above
6

If you prefer to ignore this warning for all projects you can change the preferences:

General -> Workspace -> Report missing project encoding as: Ignore

If you're using Maven, every time you run "Update project" the warning comes back, as the project configuration is re-created from the POM file. To get rid of this warning permanently, add this in your POM file:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Then, run "Update project" and the warning is gone. You can find more info here:

If you are using Maven, add something similar to the following to your pom.xml:

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${maven.resources.plugin.version}</version>
                    <configuration>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>

If you want to make this part of Eclipse settings (through eclipse task in Gradle, for example), create a file named "org.eclipse.core.resources.prefs" in .settings folder with these contents -

eclipse.preferences.version=1
encoding/<project>=UTF-8

This would be the command in gradle's eclipse task -

new File(".settings", "org.eclipse.core.resources.prefs").text = """eclipse.preferences.version=1
encoding/<project>=UTF-8
"""

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.