简体   繁体   中英

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!

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)

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM