How to change file encoding in NetBeans?
Asked Answered
A

8

100

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.

Aegyptus answered 9/11, 2010 at 11:34 Comment(1)
Stack over flow Answer By LordofFatalityPsychoneurotic
U
20

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.

Uncanny answered 9/11, 2010 at 13:1 Comment(4)
Thanks. If someone know such a tool, please post it here: superuser.com/questions/208948/…Aegyptus
@JohmM2, You can use jEdit to change the file-encoding if you didn't find something else better. You can convert files one by one on demand. I don't know automatic tool currently, especially if you have files of different encoding. You could possibly use iconv command line tool but I not sure that it will do work the best and that its the best tool.Uncanny
For future generations - for changing encoding Notepad++ can be used. Open file, see it's encoding. convert to desired one and save.Freethinker
Is there a way to change or convert an entire folder and subfolders of files?Whipping
M
195

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)

Macedoine answered 31/1, 2012 at 19:50 Comment(13)
How to find the file in mac?Teston
+1 Worked for me on Mac 10.8.. the file is located here: /Applications/NetBeans/NetBeans 7.2.1.app/Contents/Resources/NetBeans/etc/netbeans.confTestes
my netbeans 7.4 under windows 8.1 does not use this setting apparently. Still Cp1252 showed.Butt
Confirmed working on NetBeans IDE 8.0 on W7 and XP both.Nakashima
NetBeans 8.0.1 on Windows 8.1 64 bit confirmed working (just have to save the conf file to the desktop and drop back into the original folder due to Windows control-freakishness).Watusi
Working in Netbeans 8.0.2 on Windows 7Gaily
Works in Netbean 8.0.2 on Windows 8.1!Xylia
Still Ok with Netbeans 8.1/Windows7. If not done, Netbeans corrupt all accents at opening if project preference encoding is set to UTF-8.Fronde
Seems not to work for everything: netbeans.org/bugzilla/show_bug.cgi?id=179585 ... was set in that netbeans.conf, but does not work for JSPs ...Cob
where is etc folder?Amphitrite
On Windows 10 the file can be found at C:\Program Files\NetBeans 8.1\etc\netbeans.confBeanpole
worked on windows 7 + netbeans 8.2. created new .php file --> edited --> saved --> it's still utf-8! (finally!)Reproduce
Windows 11, Netbeans 13, find at C:\Program Files\NetBeans-13\netbeans\etc\netbeans.confPetasus
U
20

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.

Uncanny answered 9/11, 2010 at 13:1 Comment(4)
Thanks. If someone know such a tool, please post it here: superuser.com/questions/208948/…Aegyptus
@JohmM2, You can use jEdit to change the file-encoding if you didn't find something else better. You can convert files one by one on demand. I don't know automatic tool currently, especially if you have files of different encoding. You could possibly use iconv command line tool but I not sure that it will do work the best and that its the best tool.Uncanny
For future generations - for changing encoding Notepad++ can be used. Open file, see it's encoding. convert to desired one and save.Freethinker
Is there a way to change or convert an entire folder and subfolders of files?Whipping
S
9

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

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

Strangles answered 14/2, 2011 at 11:9 Comment(0)
N
5

There is an old Bugreport concerning this issue.

Niece answered 21/7, 2011 at 8:53 Comment(1)
I know I am necro commenting, but this high-vote post above saved me... What's unbelievable is that I spent years manually configuring encoding for every sub-option in Eclipse when it's 1 line for NB?!Watusi
C
5

On project explorer, right click on the project, Properties -> General -> Encoding. This will allow you to choose the encoding per project.

Cathryncathy answered 17/5, 2016 at 21:35 Comment(1)
I don't know about former versions of NetBeans, but currently (NetBeans IDE 8.1) this is the right solution for me. Only a little difference in the route: Properties -> Sources -> Encoding. This is because I have several projects in different languages and I could set for my projects in Spanish the encoding to ISO-8859-2 and left the rest in UTF-8 which is the recommended encoding for web projects. Thanks a lot jcarballo!Pigeontoed
W
5

Yes, you can change the encoding of a specific file (or see what it has) with this Encoding Support plugin. With this plugin you will be able to handle the different encodings of your files without problems.

Now it is in version 1.4.0 for NetBeans 8.2 and I use it in Windows 10 several time ago.

The operation is very simple, in the status line you can see the encoding of the open file, and from there you can define its new encoding.

Encoding Support running on Windows 10

Welloff answered 17/2, 2018 at 21:7 Comment(0)
V
2

This link answer your question: http://wiki.netbeans.org/FaqI18nProjectEncoding

You can change the sources encoding or runtime encoding.

Vd answered 1/5, 2013 at 23:25 Comment(0)
P
0

Just try to set the Projects Encoding to "UTF-8" and copy the file (which is encoded in iso) in the same Project (and if you dont need the old file just delete it) - now the copied file will be as UTF-8 - maybe this will help you :)

Pukka answered 21/10, 2018 at 13:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.