a225892
a225892

Reputation: 21

Maven error: unmappable character for encoding Cp1251

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!

Upvotes: 2

Views: 10004

Answers (3)

Maqsud Erjonov
Maqsud Erjonov

Reputation: 25

In my case I resolved that problem by setting new environment variable:

JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8

In the command line executing maven, run current command before executing maven command:

SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8

Upvotes: 2

Arnout Engelen
Arnout Engelen

Reputation: 6927

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)

Upvotes: 2

Thorn G
Thorn G

Reputation: 12776

You have characters in that file which are likely not mapped in the Windows codepage (which is the reference to Cp1251). Try changing the project encoding to UTF-8 or similar. Look into different encoding schemes.

Upvotes: 1

Related Questions