title: Encoding issue when building with mvn
body: <p>I'm currently working on a Maven plugin that uses JAXB. The problem is that whether I launch a clean install in IntelliJ or in a console, I don't get the same results. JAXB is reading an XML file encoded in UTF-8, which contains special characters.</p>
  
  <p>In IntelliJ, these characters are read without any problem.
  But in the console, these characters are replaced with '?' (I can see it if I do a sysout).</p>
  
  <p>I found the source of my problem, but I don't really understand it and I don't know how to solve it: when IntelliJ runs mvn, it adds an extra parameter <code>-Dfile.encoding=UTF-8</code></p>
  
  <pre><code>java -classpath /usr/share/maven/boot/plexus-classworlds-2.4.jar -Dclassworlds.conf=/usr/share/maven/bin/m2.conf -Dmaven.home=/usr/share/maven -Dfile.encoding=UTF-8 org.codehaus.plexus.classworlds.launcher.Launcher clean install
  </code></pre>
  
  <p>When I run mvn in command line, I can add this extra parameter but it will appear <em>after</em> the class name:</p>
  
  <pre><code>java -classpath /usr/share/maven/boot/plexus-classworlds-2.4.jar -Dclassworlds.conf=/usr/share/maven/bin/m2.conf -Dmaven.home=/usr/share/maven org.codehaus.plexus.classworlds.launcher.Launcher -Dfile.encoding=UTF-8 clean install
  </code></pre>
  
  <p>In both cases, if I sysout the content of <code>System.getProperty("file.encoding")</code>, I get the same value "UTF-8", but a different behaviour.</p>
  
  <p>Of course I configured my pom.xml correctly using a property like this:</p>
  
  <p><code>&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;</code></p>
  
  <p>I also tried to add a second property named "file.encoding" but it does not help.</p>
  
  <p>My question is: why does the position of this system property change the behaviour of my program, and how can I fix my problem when I run mvn from command line?</p>
  
  <p>Thanks in advance.</p>