Maven error: unmappable character for encoding Cp1251

a225892 picture a225892 · Nov 16, 2012 · Viewed 8.4k times · Source

Can't compile your project in NetBeans, here is the error:

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 4.094s
Finished at: Sat Nov 17 00:23:08 MSK 2012
Final Memory: 8M/247M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project AdminCmd: Compilation failure
C:\Users\Максим\Documents\NetBeansProjects\AdminCmd\src\main\java\be\Balor\Tools\Help\String\ACMinecraftFontWidthCalculator.java:[30,33] error: unmappable character for encoding Cp1251
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

here's the file maven on that swears

http://pastebin.com/buQEE4Fb

Project to Git - https://github.com/Belphemur/AdminCmd

If someone could put a working draft of NetBeans or Eclipse!

Answer

Arnout Engelen picture Arnout Engelen · Nov 16, 2012

This is interesting, as your pom.xml mentions

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

.. but the error message complains about Cp1251 encoding. Does the maven output mention anything else related to source encodings?

My recommendation is generally to not use any high-ASCII characters in your code, and use the \uxxxx notation instead as needed.

You can make the conversion from UTF-8 to escaped unicode at online conversion sites like http://www.endmemo.com/convert/EMUnicode.php (this particular one seems to strip leading zeroes, I don't think that's legal in Java)