Take the 2-minute tour ×

I have a JUnit test that tests adding Strings to a Dictionary custom type. Everything works fine for everyone else on a Linux/Windows machine, however, being the first dev in my shop on a mac, this unit test fails for me. The offending lines are where unicode string literals are used:

    dict.add( "Su字/会意pin", "Su字/会意pin" );
    dict.add( "字/会意", "字/会意" );

Is there a platform-independent way to specify the unicode string? I've tried changing the encoding of the file in Eclipse to UTF-8 instead of the default MacRoman, but the test still fails.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

In the flags for the javac compiler, set the -encoding flag, so in your case you'd mark it as

javac -encoding UTF-8

Check here for a quick explanation from the sun forums.

share|improve this answer
Worked like a charm! Thanks! –  layne Sep 15 '08 at 20:49
add comment

Your Answer


