If your source code is encoded in UTF-8, you must set the -encoding when compiling. Otherwise, the compiler will use the default system encoding, which is probably cp1252 in your case (Windows 7, Spanish) and does not support Arabic.
You must remove all conversions to bytes, they can only worsen the situation. Here's how it should work:
String str1 = "تعطي يونيكود رقما فريدا لكل حرف"; JOptionPane.showMessageDialog(rootPane, str1);
If you cannot set the compiler options, you can use escape codes to encode characters in ASCII. The native2ascii command line native2ascii can do this conversion for you. For example, the code generated for the above two lines would look like this:
String str1 = "\u062a\u0639\u0637\u064a \u064a\u0648\u0646\u064a\u0643\u0648\u062f \u0631\u0642\u0645\u0627 \u0641\u0631\u064a\u062f\u0627 \u0644\u0643\u0644 \u062d\u0631\u0641"; JOptionPane.showMessageDialog(rootPane, str1);
source share