title: Old and beaten ORA-12705: Cannot access NLS data files or invalid environment specified and java Locale.setDefault()
body: <p>I have a question that makes me crazy
  on my laptop i have oracle-xe 10.2.0 on ubuntu</p>
  
  <p>DB Charset : AMERICAN_AMERICA.AL32UTF8</p>
  
  <p>NLS_LANG=AMERICAN_AMERICA.AL32UTF8</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
  
  //    Default locale before overwriting is ru_RU
  //    Locale.setDefault(new Locale("EN"));
  //
      Class.forName("oracle.jdbc.driver.OracleDriver");
  
      Connection conn = DriverManager.getConnection(
          "jdbc:oracle:thin:@localhost:1521:xe", "test", "test");
      try {
      // @machineName:port:SID, userid, password
  
        Statement stmt = conn.createStatement();
        try {
          ResultSet rset = stmt
              .executeQuery("select * from test");
          try {
            while (rset.next())
              System.out.println(rset.getString(1)); // Print col 1
          } finally {
            try {
              rset.close();
            } catch (Exception ignore) {
            }
          }
        } finally {
          try {
            stmt.close();
          } catch (Exception ignore) {
          }
        }
      } finally {
        try {
          conn.close();
        } catch (Exception ignore) {
        }
      }
    }
  </code></pre>
  
  <p>If i comment Locale.setDefault i have an ORA-12705: Cannot access NLS data files or invalid environment specified exception (default locale in this case stays ru_RU), but if i set default locale to EN, then everything is all right.</p>
  
  <p>What can it mean? Why it is used Locale.getDefault value instead of NLS_LANG, like has written in every article about it?</p>
  
  <p>Thanks</p>