title: Problems with encoding files when running standalone jar
body: <p>I've got strangest problem. I have a java class that writes some data to a file. When I execute it in the eclipse all works fine (writting data in the right encoding). But when I run it as standalone JAR the encoding is broken.</p>
  
  <p>I have this in my project (in pom.xml) :</p>
  
  <pre><code>&lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  &lt;/properties&gt;
  </code></pre>
  
  <p>My java class has property in eclipse (right click -> properties) file encoding set to : UTF-8.</p>
  
  <p>Here is java code snipped that does appending :</p>
  
  <pre><code> //class field
      static BufferedWriter wr;
  public static void main(String[] args) throws IOException {
          OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(args[0], true), "UTF-8");
          wr = new BufferedWriter(writer);
          //.processing logic, building up what needs to be in the file, line by line
          wr.close();
      }
  </code></pre>
  
  <p>Relevant method that does appending to .csv file :</p>
  
  <pre><code>private void writeToCSVFile(String content){
  
          try {
              System.out.println(content);
              wr.write(content);
              wr.write("\n");
              wr.flush();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Again when I print in the eclipse the output looks fine just as it does in the file I'm appending to. But when running as standalone jar encoding breaks for some reason. This is how I configure my relevant plugin(s) :</p>
  
  <pre><code>&lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;install&lt;/id&gt;
                          &lt;phase&gt;install&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;sources&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;finalName&gt;Worker&lt;/finalName&gt;
                      &lt;appendAssemblyId&gt;false&lt;/appendAssemblyId&gt;
                      &lt;descriptorRefs&gt;
                          &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                      &lt;/descriptorRefs&gt;
                      &lt;archive&gt;
                          &lt;manifest&gt;
                              &lt;mainClass&gt;com.test.automation.Testing&lt;/mainClass&gt;
                          &lt;/manifest&gt;
                      &lt;/archive&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>I really have no clue what to do next. Any ideas?</p>
  
  <p><strong>This code doesn't have any exceptions, doesn't fail anywhere. Runs exactly as intended in eclipse, when I check the file in which the results are written.</strong></p>
  
  <p>It works as standalone jar as well, but only when I check the file in which results are written encoding is screwed up.</p>