ant: warning: unmappable character for encoding UT

2020-06-08 20:01发布

I have seen numerous of questions like mine but they don't answer my question because I'm using ant and I'm not using eclipse. I run this code: ant clean dist and it tells me numerous times that warning: unmappable character for encoding UTF8.

I see on the Java command that there is a -encoding option, but that doesn't help me cuz I'm using the ant.

I'm on Linux and I'm trying to run the developer version of Sentrick; I haven't made no modifications to anything, I just downloaded it and followed all their instructions and it ain't makes no difference. I emailed the developper and they told me it was this problem but I suspect that it is actually something that gotta do with this error at the end:

BUILD FAILED
/home/daniel/sentricksrc/sentrick/build.xml:22: The following error occurred while executing this line:
/home/daniel/sentricksrc/sentrick/ant/common-targets.xml:83: Test de.denkselbst.sentrick.tokeniser.components.DetectedAbbreviationAnnotatorTest failed

I'm not sure what I'm gonna do now because I really need for it to work

标签: java linux ant
3条回答
对你真心纯属浪费
2楼-- · 2020-06-08 20:09

The problem is not eclipse or ant. The problem is that you have a build file with special characters in it. Like smart quotes or m-dashes from MS Word. Anyway, you have characters in your XML file that are not part of the UTF-8 character set. So you should fix your XML to remove those invalid characters and replace them with similar looking but valid UTF-8 versions. Look for special characters like &#64 © — ® etc. and replace them with the (c) or whatever is useful to you.

BTW, the bad character is in common-targets.xml at line 83

查看更多
成全新的幸福
3楼-- · 2020-06-08 20:09

Changing encoding to Cp 1252 worked for my project with same error. I tried changing eclipse properties several times but it did not help me in any way. I added encoding property to my pom.xml file and the error gone. http://ctrlaltsolve.blogspot.in/2015/11/encoding-properties-in-maven.html

查看更多
时光不老,我们不散
4楼-- · 2020-06-08 20:22

Try to change file encoding of your source files and set the Default Java File Encoding to UTF-8 also.

For Ant:

add -Dfile.encoding=UTF8 to your ANT_OPTS environment variable

Setting the Default Java File Encoding to UTF-8:

export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8

Or you can start up java with an argument -Dfile.encoding=UTF8

查看更多
登录 后发表回答