0

I have a test that passes in eclipse but fails in Maven due to a unicode problem. The test uses this character: ä - the test checks the length of the character, in eclipse its one but maven converts it to 2 characters: ├ñ. Does anyone know how I can get maven to behave the same as eclipse?

So far I have tried adding

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

to the pom for both the root and the project the test sits in. Plus I have tried adding directly to the maven plugin part of the pom as follows:

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
    <!-- <version>2.1</version>-->
<configuration>
  <outputEncoding>UTF-8</outputEncoding>
</configuration>

Eclipse is set to use UTF-8. Im running out of ideas. If there is anything im obviously doing wrong please let me know.

Why is this working fine in Eclipse but not Maven?!

Thanks,

8
  • Did you ensure that the file containing ä is encoded in UTF-8? For example, by looking at the hex dump of the file. Commented Dec 13, 2012 at 14:53
  • How do i ensure that? like where can i find the hex dump? I inspected the file in eclipse and it is set to UTF-8... Commented Dec 13, 2012 at 14:55
  • 1
    why not just remove the unicode character from your source file per my answer? Commented Dec 13, 2012 at 15:26
  • 1
    the form of the character in your source code has nothing to do with how users are typing them in. unless your users are typing in actual java source code. Commented Dec 13, 2012 at 15:39
  • 1
    Iv inspected the object in the hex editor and it is indeed 0xC3 0xA4 Commented Dec 13, 2012 at 15:40

2 Answers 2

1

Your best bet is to avoid using unicode characters in your source files. instead, use the unicode escape syntax, i.e. "\u00E4".

Sign up to request clarification or add additional context in comments.

1 Comment

care to explain the downvote? my answer is a legitimate solution to the problem even if the OP doesn't realize it.
1

Try setting this in the plugin's configuration:

<plugin>
    ...
    <configuration>
        ...
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>

1 Comment

Hi, thanks for the tip. I tried this and it still failed. Tried it with <outputEncoding> as well but that fails as well...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.