title: Trying to show arabic characters in Java
body: <p>I am trying to show <strong>arabic characters</strong> in a Java applet but I always get <strong>Questions marks</strong> '?????'.</p>
  
  <p>I tried many solutions with no success:</p>
  
  <ul>
  <li><a href="http://www.philvarner.com/blog/2009/10/26/unicode-in-java-bytes-and-chars-part/" rel="noreferrer">Using new String(bytes [], charsetName) to UTF-8 decode</a>.</li>
  <li>Changing default Charset in Netbeans: -Dfile.encoding=UTF8 in VM options and -encoding UTF8 in compiling options.</li>
  <li>Using ByteArrayOutputStream for encoding.</li>
  <li>Using both UTF8 and UTF-8 charset names.</li>
  </ul>
  
  <p>I am using Windows 7 in a spanish language environment.</p>
  
  <p>Some solutions <strong>work when running Netbeans, but they do not work outside this environment</strong>. Here it is <a href="http://dl.dropbox.com/u/639494/JavaApplication4.rar" rel="noreferrer">Netbeans project with sources and .jar</a>.</p>
  
  <p>This is simple code I am using:</p>
  
  <pre><code>package javaapplication4;
  
  import java.io.ByteArrayOutputStream;
  import java.nio.charset.Charset;
  import javax.swing.JApplet;
  import javax.swing.JOptionPane;
  
  public class JavaApplication4 extends JApplet{
  
  @Override
  public void init(){
      try {
  
          String str1 = new String("تعطي يونيكود رقما فريدا لكل حرف".getBytes(), "UTF-8");
          JOptionPane.showMessageDialog(rootPane, str1);
  
          String str2 = new String("تعطي يونيكود رقما فر");  
          ByteArrayOutputStream os = new ByteArrayOutputStream();
          os.write(str2.getBytes());
          JOptionPane.showMessageDialog(rootPane, os.toString("UTF-8"));
  
      } catch (Exception ex) {
          JOptionPane.showMessageDialog(rootPane, ex.toString());
      }
  }
  }
  </code></pre>
  
  <p>Any idea of what is happening?</p>