How to change file encoding in NetBeans?

I want to change encoding of file in NetBeans IDE (ver 6.9.1), let's say from ANSII to UTF-8. How can I do that?

EDIT: I will be more precise. I don't want to change the default encoding in NetBeans. I want to only change encoding of the currently edited file.


Solution 1:

Go to etc folder in Netbeans home --> open netbeans.conf file and add on netbeans_default_options following line:

-J-Dfile.encoding=UTF-8

Restart Netbeans and it should be in UTF-8

To check go to help --> about and check System: Windows Vista version 6.0 running on x86; UTF-8; nl_NL (nb)

Solution 2:

In NetBeans model all project files should have the same encoding. The answer is that you can't do that in Netbeans.

If you are working in Netbeans you should consider to convert all files to a single encoding using other tools.

Solution 3:

The NetBeans documentation merely states a hierarchy for FileEncodingQuery (FEQ), suggesting that you can set encoding on a per-file basis:

  • NetBeans wiki article "DevFaqI18nFileEncodingQueryObject": Project Encoding vs. File Encoding - What are the precedence rules used in NetBeans 6.x?

Just for reference, this is the wiki-page regarding project-wide settings:

  • NetBeans wiki article "FaqI18nProjectEncoding": How do I set or modify the character encoding for a project?

Solution 4:

There is an old Bugreport concerning this issue.