1

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)

Yauhen
  • 2,435
  • 1
  • 17
  • 18

4 Answers4

2

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.

Community
  • 1
  • 1
Yauhen
  • 2,435
  • 1
  • 17
  • 18
2

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"));
Jeff_Alieffson
  • 2,672
  • 29
  • 34
  • 1
    A variation of your second change would be to set `-Dfile.encoding=utf-8` for _Properties > Run > VM Options_ within the project's properties instead. Then you wouldn't need to set the encoding for the `PrintStream` to _"UTF8"_ in the code, and you could just call `System.out.println()` in the usual way. – skomisa Jan 05 '20 at 05:46
  • @skomisa , i didnd any printstrims, just first option and yours and its shows local language letters pretty ok now! Talking about Apache Netbeans 12.5 – CodeToLife Nov 27 '21 at 11:33
0

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.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • Thank you for reply, but the main problem I can't find suitable settings. I can find and hold it in previous versions of NB, but not in this one 7.2. Please, if you've found it, let my weird attention to know. – Yauhen Sep 27 '12 at 09:14
0

you can add system variable in mycomputer

JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
Jewel
  • 363
  • 4
  • 9