I have often seen problems arise with encoding. Therefore I have written down this instruction set to do all the needed actions in order to make things work (with encoding). This set is related to Eclipse but it will also guide with maven settings.
The issue with encoding is most problematic when using scandinavian letters in java files (åäö, and they had actual meaning on runtime).
An example case is having a constant variable in a java file, that contains a scandic letter and it is used to identify a value from incoming stream (wich is in UTF-8).
Also the underlying OS may be Windows and they use cp1252 by default.
E.g. the following code:
@Test
public void scandicTest() {
System.out.println("scandics: åäö");
}
When everything is configured correctly (e.g. in eclipse), running this test will produce:
scandics: åäö
But if you run this via Maven (from command line or in eclipse => mvn test), you will have:
scandics: ���
First of all, the encoding needs to be changed in eclipse and also in the maven pom.xml to read and store files correctly and for the eclipse to use correct encoding when saving the files / running tests. However the constant value in the java file itself remains corrupted even that the files read in are correct (containing the scandic letters) when the Maven and the resulting java code handled the incoming streams (compiled & run the tests).
The System Java still uses a OS specific default encoding even that everything else is set correctly. For this reason you can not configure all within the project, you must do it for the OS-JVM also.