Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use UTF-8 character in Netbeans

I am using Netbeans6.9.1 IDE and wants to show the Chinese characters in the output console using java. I copied the Chinese charater from a web page and copied between the "". but its not supported.

         String char1="世界你好";
         System.out.println(char1);

Do I need to do some setting in IDE or use some settings in my Java code?

like image 976
sjain Avatar asked Feb 04 '11 09:02

sjain


People also ask

How do I change character encoding in NetBeans?

On project explorer, right click on the project, Properties -> General -> Encoding. This will allow you to choose the encoding per project. I don't know about former versions of NetBeans, but currently (NetBeans IDE 8.1) this is the right solution for me.

What is the use of UTF-8 in Java?

UTF-8 is a variable width character encoding. UTF-8 has the ability to be as condensed as ASCII but can also contain any Unicode characters with some increase in the size of the file. UTF stands for Unicode Transformation Format. The '8' signifies that it allocates 8-bit blocks to denote a character.

What characters are not allowed in UTF-8?

Yes. 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF are invalid UTF-8 code units.

Where is NetBeans config file?

The netbeans. conf file is located at Contents/Resources. NetBeans/etc/netbeans. conf within the package contents.


1 Answers

Edit the file netbeans.conf from the etc directory located at the installation directory of NetBeans. In the netbeans_default_options option, add -J-Dfile.encoding=UTF-8.

Works for both console input and output in NetBeans.

like image 194
Mate Šimović Avatar answered Oct 30 '22 23:10

Mate Šimović