|utf-8 encoding [message #732026]
||Mon, 03 October 2011 14:03
Registered: February 2011
I'm attempting to alter the encoding value for the workspace. I wish for my source files to be encoding using utf-8.
I have discovered that I can change a setting in
Eclipse -> Preferences -> General -> Editors -> TextEditors -> Spelling
About half way down the screen I can see "Encoding". The default value was MacRoman so I selected "Other" and selected "UTF-8" from the drop down.
Is this the only place where that setting is made?
|Re: utf-8 encoding [message #733417 is a reply to message #733271]
||Tue, 04 October 2011 12:50
| Larry Isaacs
Registered: July 2009
On 10/4/2011 11:32 AM, linen wrote:|
> I've tried to add arguments to the runtime profile for Java. I'm using
> Eclipse Helios.
> Eclipse -> Preferences -> Java -> Installed JREs
> I select the JRE, click "Edit" and I have added the following to the
> text field "Default VM Arguments" -> -Dfile.encoding=UTF-8.
> I've also added that to the bottom of the eclipse.ini file in the
> Application Bundle in Mac OS X. I restarted my computer. But I still
> don't see proper character formatting. I'm just confused about how to
> set encoding for a Java application. I can choose "Irish Extended" from
> the Character Palatte, which I've set up inside of System Preferences on
> OS X. I can type Irish including the Irish fada directly into the
> Eclipse editor. And I can type Irish and the fada directly into the
> console. So I know the font is fine, and I know that Eclipse can display
> the character. It just isn't showing up in when I run the Java
> application. And I don't know what I'm missing or failing to understand.
Since you say you are running your application within Eclipse, I'm going
to guess that you are looking at the output in the Console window. If
this is correct, setting the "-Dfile.encoding=UTF-8" on the JRE tells
the JVM what encoding you want. However, it doesn't tell the Console
view what encoding to expect. In this case, instead of setting the
"Default VM Arguments", you want Run -> Run Configurations. Select the
launch configuration under the Java Application category. On the Common
tab, select the encoding in the Encoding section. This will set the
"file.encoding" system property for the JVM and tell the Console view to
expect that encoding. If I've guessed wrong, please specify where you
are viewing the incorrect output. I'm not sure how else to interpret
"view output in Log 4 J".
|Re: utf-8 encoding [message #733449 is a reply to message #733417]
||Tue, 04 October 2011 14:47
Registered: February 2011
Eclipse Java EE Version : Helios Service Release 1|
Mac OS X 10.5.8
Many Thanks for your response. Okay I've accessed the Common Tab and I can see the Encoding option. The radio button that is selected when I open the tab is "Default - inherited (UTF-8)" So I've made no change. I've restarted Eclipse and rerun the application and I still can't see the fada character in the console when I attempt to print the data that is running through the application.
However, I can see the following : System.out.println("Tá sé seo deacair");
That will print the following in the console:
Tá sé seo deacair
Which is exactly predictable and correct. So now I don't think this is an Eclipse issue after all.? Moreover, when I export my application to a war file and run it from my Tomcat instance outside of Eclipse, I am still having problems with printing and viewing runtime data.
So I may need to search elsewhere for the solution to this - But thanks for your help.
Powered by FUDForum
. Page generated in 0.02098 seconds