Output window in Netbeans 7.2 can't correctly display thai symbols

4.7k Views Asked by At

Need your help. I have an annoying issue: thai symbols can't be printed pretty in Netbeans 7.2 output window:

Output after System.out.println(...); ???????????????????[TH_WORD]

I changed netbeans.conf as mentioned, it doesn't help; I changed project properties->Sources encoding to UTF-8 and sources looks good, all thai symbols in sources are correctly printable. But how to change settings of NB output window?

Windows 7 64bit, Netbeans 7.2 (I run NB as "C:\Program Files (x86)\NetBeans 7.2\bin\netbeans64.exe" --locale en_US)

4

There are 4 best solutions below

2
On

For Azerbaijani language I tried this:

  • added System.setOut(new PrintStream(System.out, true, "UTF8")); into my code. After this correction it changed ? marks into different symbols. The word tədarük before displayed as t?dar?k. But now it standed tЙ™darГјk
  • then I added -Dfile.encoding=utf-8 into the Run arguments on Project properties, no way
  • then tested with -Duser.language=az, result was the same
  • changed the font on Output console (right click on console and on Settings window changed Monospaced font into Arial, nothing changed

It did not help. Only after changing Netbeans config it worked. I opened netbeans.conf, in my case it was in C:\Program Files\NetBeans 7.4\etc folder, on linux it'll /usr/local/netbeans-7.4/etc/netbeans.conf

I added -J-Dfile.encoding=UTF-8 into the end of netbeans_default_options just before the quotation mark. Restarted NetBeans. Now it works even with Monospaced font and without setting -Duser.language param.

So I needed only two things.

  1. add -J-Dfile.encoding=UTF-8 into netbeans_default_options in netbeans.conf
  2. change output string encoding in your code: System.setOut(new PrintStream(System.out, true, "UTF8"));
1
On

The solution will be to change the font being used for the console output window to one that includes Thai characters. In Eclipse this is possible in the Preferences dialog. It's been at least 5 years since I used NetBeans, but I'm 99% certain something similar is available there too.

0
On

Solved thanks to conversation Java: How to detect (and change?) encoding of System.console?

The solution was founded and applied:

PrintStream out = new PrintStream(System.out, true, "UTF-8");

use appropriate import java.io.*, indeed.

0
On

you can add system variable in mycomputer

JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8