This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 198226 - runtime.encoding cannot be set
Summary: runtime.encoding cannot be set
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Assignee: Tomas Zezula
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2011-05-01 22:30 UTC by daniel_fullum
Modified: 2011-05-25 07:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description daniel_fullum 2011-05-01 22:30:03 UTC
My PC is set to use IBM850 when using a command line window. I am using SE 7.0
As specified in http://wiki.netbeans.org/FaqI18nProjectEncoding I added
runtime.encoding=IBM850 to private.properties.
Accentuated French characters still won't display correctly unless I use
java -Dfile.encoding=Cp850 <class>
Comment 1 Tomas Zezula 2011-05-25 07:44:20 UTC
Works fine for me.
The runtime.encoding is correctly passed to VM. (Tested on J2SE project type).

You can test it by:
 System.out.println(System.getProperty("file.encoding"));

But be careful the runtime.encoding is an expert option which in 99% of cases is not needed. In fact it's needed only in case when the source encoding differs from the required runtime encoding. As far s I remember it was added to support some file based database which required specific encoding.

Setting the runtime.encoding is the same as passing the -Dfile.encoding to java. The Ant's java task just do it for you. I don't understand much the

>java -Dfile.encoding=Cp850 <class>

if you run the application from command line using java not by the IDE generated Ant script the runtime.encoding cannot help you as it's an Ant java task parameter.
Just to clarify. The IDE uses source.encoding (which is the common way to set encoding). The source.encoding is a parameter to Ant's javac task (javac -encoding option) which is used by the compiler to correctly encode the source files. The strings in the compiled byte code are always UTF-8 (vm spec chapter 2.3.3). When you run the app in the IDE (by IDE generated ant script) the ant starts a Java VM with -Dfile.encoding=${runtime.encoding} option. If it's not set in properties file it defaults to source.encoding which is the most common behavior. In some case like the file database mentioned above you need to create java VM with some specific encoding which differs to source.encoding. You can set the runtime.encoding.
When you execute the app from the command line using (java classname) the OS encoding is used, if you need to specify different one you need to uses -Dfile.encoding