title: Command 'hadoop jar' Doesn't Take -Dfile.encoding=UTF-8?
body: <p>Consider the following main class for map-reduce job:</p>
  
  <pre><code>public class App extends Configured implements Tool {
  
      public static void main(String[] args) throws Exception {
          ToolRunner.run(new App(), args);
      }
  
      @Override
      public int run(String[] args) throws Exception {
          System.out.println(Charset.defaultCharset().toString());
          return 0;
      }
  
  }
  </code></pre>
  
  <p>When using in interactive shell, it outputs 'UTF-8'. When using in crontab, it's 'US-ASCII'.</p>
  
  <p>But use 'java -Dfile.encoding=UTF-8 -jar xxx.jar', it works fine in crontab. However, 'hadoop jar' command doesn't take this parameter:</p>
  
  <pre><code>hadoop jar xxx.jar -Dfile.encoding=UTF-8
  </code></pre>
  
  <p>In crontab, it still outputs US-ASCII.</p>
  
  <p>One solution is export a LC_ALL env:</p>
  
  <pre><code>0 * * * * (export LC_ALL=en_US.UTF-8; hadoop jar xxx.jar)
  </code></pre>
  
  <p>Is there another way?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Another env I find useful is HADOOP_OPTS:</p>
  
  <pre><code>0 * * * * (export HADOOP_OPTS="-Dfile.encoding=UTF-8"; hadoop jar xxx.jar)
  </code></pre>