Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Encoding properties in Maven

Recently while building one of my maven projects I came across a weird issue. The same project when I build on my windows server it gets build properly without any errors.

However when I moved my project to Linux (Ubuntu), it started showing me encoding error.

The error appeared like below:
File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!

It keep failing compilation of several of my java files.

I searched a lot on google and finally found below solution which worked just fine for my project. The files got compiled properly after that and build got successful.

So here is the solution: :)

Whenever you see above error just modify your project's pom.xml file as below.

- Locate or add <properties> tag in your pom.xml file and add encoding you require.

In my case I required Cp1252 encoding to get the compilation and build successful.
<properties>
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
</properties>

Alternatively you can use UTF-8 encoding as below.

<properties>
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
</properties>

Hope this solution makes your build successful too... cheers.! :)


This post first appeared on Ctrl+alt+solve, please read the originial post: here

Share the post

Encoding properties in Maven

×

Subscribe to Ctrl+alt+solve

Get updates delivered right to your inbox!

Thank you for your subscription

×