Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is the -Dfile.encoding server setting used for compliation of Java classes?

 
Adrian Airmil
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont work on servers but our server guy set the java start up options on unix as follows -Dfile.encoding=ISO-8859-1 and all the content coming from a form in a JSP is now being returned with the right encoding for special chars.

Does anyone know if this change means that this encoding is also used when the java classes in the app are compiled as well? or is it only used to set the encoding of the JSP's? Note: the app gets compiled on the server using Maven.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know if this change means that this encoding is also used when the java classes in the app are compiled as well?


It would not matter if the encoding is applied at compile time. The option that you mentioned is the default one that is consulted when a program runs at runtime. More here -> http://www.jguru.com/faq/view.jsp?EID=78088

Did you mean to say runtime ?
 
Adrian Airmil
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:
Does anyone know if this change means that this encoding is also used when the java classes in the app are compiled as well?


It would not matter if the encoding is applied at compile time. The option that you mentioned is the default one that is consulted when a program runs at runtime. More here -> http://www.jguru.com/faq/view.jsp?EID=78088

Did you mean to say runtime ?

No, I was referring to compile time. I de-compiled the class and the special chars, that are used in property values, show up as '\uFFFD'. Thus at run time they get rendered as a '?'. I was wondering if that default option also gets used at runtime. In that case I dont have to look into specifying encoding in Maven for the compilation of the app.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no concept of choosing encoding at compile time. Encoding is always decided when the conversion occurs.

I de-compiled the class and the special chars, that are used in property values, show up as '\uFFFD'


You are probably looking at a constant that was stored as 16 bit unicode.

Thus at run time they get rendered as a '?'


The \uFFFD character is a place holder for those characters that cannot be converted correctly.
 
Adrian Airmil
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:There is no concept of choosing encoding at compile time. Encoding is always decided when the conversion occurs.

Really? I'm confused now. I received this advice : Special chars not being sent correctly in email
And since we are using Maven I was considering this : Specifying a character encoding scheme

But before doing that I wanted to verify if the -Dfile.encoding server setting was used for compliation of Java classes when the app is compiled on the server/unix box and hence this thread. If the answer is yes then I dont need to change any POM file to rebuild the app.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adrian,

It appears I was incorrect. The javac documentation does mention a -encoding flag during compilation time.

http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javac.html

I have never had to deal with this before, so the flag escaped my attention. I am not sure how the replacement character came to be. Perhaps like you mention, the flag must have not been used during compile time. I will play around with the flag and try to confirm this for you.

Sorry about confusing you previously.
 
Adrian Airmil
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the clarification, Deepak. I've never had to use the -encoding flag before as well and hence all these questions

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic