GeeCON Prague 2014*
The moose likes BEA/Weblogic and the fly likes Is the -Dfile.encoding server setting used for compliation of Java classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Is the -Dfile.encoding server setting used for compliation of Java classes?" Watch "Is the -Dfile.encoding server setting used for compliation of Java classes?" New topic
Author

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

Adrian Airmil
Greenhorn

Joined: Dec 12, 2005
Posts: 24
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

Joined: Feb 24, 2006
Posts: 6661
    
    5

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 ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Adrian Airmil
Greenhorn

Joined: Dec 12, 2005
Posts: 24
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

Joined: Feb 24, 2006
Posts: 6661
    
    5

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

Joined: Dec 12, 2005
Posts: 24
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

Joined: Feb 24, 2006
Posts: 6661
    
    5

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

Joined: Dec 12, 2005
Posts: 24
Thanks for the clarification, Deepak. I've never had to use the -encoding flag before as well and hence all these questions

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is the -Dfile.encoding server setting used for compliation of Java classes?