File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Best practise for setting character encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Best practise for setting character encoding" Watch "Best practise for setting character encoding" New topic
Author

Best practise for setting character encoding

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hi,
We always want UTF-8.
Is it better to set this as a system property passed to the JVM e.g.
-Dfile.encoding=UTF-8

Or is it better to set it programmatically:

System.setProperty("file.encoding", "UTF-8");

And why?

Thanks.

Eduardo Yañez Parareda
Ranch Hand

Joined: Oct 09, 2008
Posts: 92

It depends on your enviroment, I prefer to have it in a configuration file, then set it programmatically. That way you don't depend on Server Applications Admins, and it isn't hardcoded.


http://serfj.sourceforge.net - Simplest Ever REST Framework for Java
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best practise for setting character encoding