43

I'm wondering if I can change default encoding in NetBeans 8.0... I searched a lot but I haven't find a way how to change the encoding in this version of NetBeans.

I have this tag in my html document: <meta charset="utf-8">

BUT! As you can see on attached image, NetBeans notice is warning me about an encoding problem.

Internal encoding declaration "utf-8" disagrees with the actual encoding of the document ("windows-1250")

Internal encoding declaration "utf-8" disagrees with the actual encoding of the document ("windows-1250").

I created index.html by "new file" function in NetBeans. There is UTF-8 encoding in project properties, so I think it should be UTF-8. I really don't know where that 'windows-1250' came from!!

Where I can find some option to change default encoding or even current file encoding in NetBeans 8.0?

Daniel Lengyel
  • 443
  • 1
  • 4
  • 5

3 Answers3

105

Solution given by Danny

Navigate to <Netbeans installation directory>/etc and open the netbeans.conf file.

Add -J-Dfile.encoding=UTF-8 at the end of the line that starts with netbeans_default_options (make sure to include the leading space).

Restart Netbeans and it should be in UTF-8

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

Community
  • 1
  • 1
Rex Wagenius
  • 1,302
  • 1
  • 12
  • 13
  • Thank you, Rex! It seems to be an answer. First I misunderstood this solution and I was searching this line of code... Then I see the word "add" and suddenly everything becomes clear :D Problem solved... thanks again. – Daniel Lengyel Jul 18 '14 at 20:18
  • 2
    Thank you! Works perfectly the encoding to UTF8. I find netbeans.conf file on C:\Program Files\NetBeans 8.0.1\etc Added at end of Line 46 your trick ;) : netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true **-J-Dfile.encoding=UTF-8**" – gtamborero Feb 06 '15 at 05:43
  • 1
    The answer is slightly misleading: 'Netbeans home', it least to me, implies 'NetBeans user home' while the file is actually in the etc directory under the NetBeans installation directory – Andrei LED Oct 09 '18 at 23:52
  • @Andrei LED: Thx for the feedback, I've updated the answer. – Rex Wagenius Nov 26 '18 at 12:15
  • Instead of posting an answer which merely links to another answer, please instead [flag the question](/help/privileges/flag-posts) as a duplicate. – Sabito stands with Ukraine Jan 30 '21 at 07:07
  • Can't remember the exact reasoning since this was almost 7 years ago. But I think I though there was a distinct difference since the original question was about changing the encoding of _one_ file and this one is for the default encoding. The answer I'm referring to isn't an actual answer to the original question but rather to this one. But I can of course see your point and won't argue against it, I simply wanted to explain my reasoning. – Rex Wagenius Feb 19 '21 at 12:58
11

Answer here worked well for me on Netbeans 7.3 Stackoverflow Answer

Right click on the project name and click on properties. Sources tab -> Encoding and change it to whatever you need. In my case i needed Windows 1252 encoding.

Community
  • 1
  • 1
Lloyd Erasmus
  • 402
  • 10
  • 17
  • 2
    This is a best answer because you probably only need a different encoding setting per project. – jcarballo May 17 '16 at 21:33
  • But it seems it does not change the encoding of existing files – furins Aug 25 '16 at 17:38
  • I encounter an encoding problem with .properties file. I opened a properties dialog via context menu in Files for that file and set 'Use project encoding' option. – Joter Mar 13 '23 at 11:14
3

I had the problem with a cyrillic characters (russian and ukranian letters) in netbeans 8.1 for Ubuntu 14.04. I have fixed problem like @Rex Wagenius adviced + I had to change a font of netbeans (in main menu: Tools -> Option -> Fonts&Colors -> Syntax tab -> Font changed from Courier to Serif 20). Hope this answer will be helpful for some users with the same problem.

Vaha
  • 2,179
  • 2
  • 17
  • 29
  • 1
    I was using Liberation Mono. Changing to DejaVu Sans Mono fixed my problem. If anyone reading this is having trouble displaying UTF8 characters, try changing the IDE font to something else – kurdtpage Aug 23 '18 at 08:43