Specify encoding for Maven projects View article history Edit article

Published: , Updated:
Talks about: <a class="post-tag post-tag-encoding" href="/tags/encoding">encoding</a>, <a class="post-tag post-tag-linux" href="/tags/linux">linux</a>, <a class="post-tag post-tag-mac" href="/tags/mac">mac</a>, <a class="post-tag post-tag-maven" href="/tags/maven">maven</a>, and <a class="post-tag post-tag-windows" href="/tags/windows">windows</a>

Maven projects by default use the file encoding of the operating system. This can be problematic in case different operating systems with different encoding settings are used to build the project. Specify the encoding of your source code and resource files as in the following snippets to fix that problem.

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