Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving JSP as UTF-8 in NetBeans

i've got some jsp files from another developers and now need to work with them. When i add to the document any UTF-8 char and want to save the document, NetBeans automatically offers me saving in ISO-8859-1.

Actually i'm getting this message from NetBeans:

The index.jsp contains characters which will probably be damaged during conversion to the ISO-8859-1 character set. Do you want to save the file using this character set? (Yes/No)

NB didn't offer me any other option like saving the file as UTF-8 (as it should be already written in).

I don't know how to save those jsp files in the character set they are already written in.

And don't tell me, that changing the content of the file itself (which is uneffective due to including headers etc. from other files) is the only way...

http://forums.netbeans.org/topic8750.html

like image 980
Radek Simko Avatar asked Feb 04 '11 16:02

Radek Simko


1 Answers

Firstly; don't forget to consider this line at top:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

Secondly; In the NetBeans folder there is a config file. There should be a line like that:

netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"

Add this to the end of the line:

-J-Dfile.encoding=UTF-8 

Thirdly:

NetBeans implements a project encoding setting.

To change the language encoding for a project:

  1. Right-click a project node in the Projects windows and choose Properties.
  2. Under Sources, select an encoding value from the Encoding drop-down field.

The encoding affects at least:

* how non-ASCII characters are displayed in the editor window when you open files
* Java file compilation of sources containing non-ASCII identifiers, string literals, or comments
* textual search for international characters over the project 

Starting from NetBeans IDE 6.8, you can also specify the encoding that will be used at runtime. For example, this can be useful when the encoding for the operating system on which the application will run is different from your project's encoding.

To specify the encoding to be used at runtime:

  1. In the Files window for your project, open nbproject > private > private.properties
  2. Add the following line to the private.properties file and save changes:

runtime.encoding = < encoding >

This encoding will override the encoding setting for your project and will be used when running your application.

In general,

*.properties files always use ISO-8859-1 encoding plus \uXXXX escapes. (International characters will be displayed natively in the editor but stored as an escape on disk.)
*.xml files and some *.html files can specify their own encodings, regardless of the project encoding. For such files, the IDE's editor ignores the project encoding. 

These may help you.

Sources for my answer that I used:

Link1: http://forums.netbeans.org/topic33.html

Link2: http://wiki.netbeans.org/FaqI18nProjectEncoding

like image 52
kamaci Avatar answered Oct 20 '22 04:10

kamaci